sql-server-2008

selectively execute task in ssis control flow

I have a SSIS package with a control flow containing a bunch of execute sql tasks in a sequence. I need to check a flag for each of the tasks and run the task if it is set, if not skip and go to the next one. Each of the these task executes a stored proc. So i can check in the proc and "Return" if not set. I was looking for a "SSIS" s...

How to add "missing" columns in a column group in reporting services?

Hello, I'm trying to create a report that displays for each months of the year the quantity of goods sold. I have a query that returns the list of goods sold for each month, it looks something like this : SELECT Seller.FirstName, Seller.LastName, SellingHistory.Month, SUM(SellingHistory.QuantitySold) FROM SellingHistory JOIN Seller o...

What is the most effective and flexible way to generate combinations in TSQL?

What is the most effective and flexible way to generate combinations in TSQL? With 'Flexible', I mean you should be able to add easily combination rules. e.g.: to generate combinatories of 'n' elements, sorting, remove duplicates, get combinatories where each prize belongs to a different lottery, etc. For example, Having a set of number...

SQL GUID Vs Integer

Hi I have recently started a new job and noticed that all the SQL tables use the GUID data type for the primary key. In my previous job we used integers (Auto-Increment) for the primary key and it was a lot more easier to work with in my opinion. For example, say you had two related tables; Product and ProductType - I could easily cro...

SQL Server Job with precise timing

Hi, I have a DB with game data (map, players, etc...) and I have a game core mechanics written in T-SQL stored procedure. I need process game loop (via the stored procedure) every "X" seconds. I tried used the SQL Job, but when I set the interval to seconds, the SQL server stops responding. If I set the interval greater than one minut...

SQL Server 2008 Sql snippets

I think that this is a relatively simple question. I just want to know if you are able to save or use SQL snippets like you can in Visual Studio, but within SQL Server Management Studio? I've had a browse but couldn't find anything. ...

switch case in where clause

hi, i need to check three conditions: if @filter = 1 { select * from employeestable where rating is not null } else if @filter = 2 { select * from employeestable where rating is null } else { select * from employeestable } This i need to do using a case statement. now i have more than 30 lines of query, if i use case i ...

How to analyze 'dbcc memorystatus' result in SQL Server 2008

Currently i am facing a sql memory pressure issue. i have run 'dbcc memorystatus', here is part of my result: Memory Manager KB ---------------------------------------- ----------- VM Reserved 23617160 VM Committed 14818444 Locked Pages Allocated ...

Select row data as ColumnName and Value

I have a history table and I need to select the values from this table in ColumnName, ColumnValue form. I am using SQL Server 2008 and I wasn’t sure if I could use the PIVOT function to accomplish this. Below is a simplified example of what I need to accomplish: This is what I have: The table’s schema is CREATE TABLE TABLE1 (ID INT...

SQL Server 2008 - Script Data as Insert Statements from SSIS Package

SQL Server 2008 provides the ability to script data as Insert statements using the Generate Scripts option in Management Studio. Is it possible to access the same functionality from within a SSIS package? Here's what I'm trying to accomplish... I have a scheduled job that nightly scripts out all the schema and data for a SQL Server ...

SQL Server Multiple Running Totals

I have a table like this UserID Score Date 5 6 2010-1-1 7 8 2010-1-2 5 4 2010-1-3 6 3 2010-1-4 7 4 2010-1-5 6 1 2010-1-6 I would like to get a table like this UserID Score RunningTotal Date 5 6 6 2010-1-1 5 4 10 2010-1-3 6...

Combining two tables with SSIS into one destination table

Hi all, I am new to SSIS, so please bear with me. I created an Integration Services Project for SQL Server 2008 to import data from an old db to a new one. One of the things I need to do is import data from two old source tables into one new destination table. What is the best way to do this? I can easily see the results I want wit...

SQL Server: Can you help me with this query?

I want to run a diagnostic report on our SQL Server 2008 database server. I am looping through all of the databases, and then for each database, I want to look at each table. But, when I go to look at each table (with tbl_cursor), it always picks up the tables in the database 'master'. I think it's because of my tbl_cursor selection : ...

What is the Datatype for 10:00 AM PST in SQL Server

Hi I have a table that need to store Timeslot such as 10:00 AM PST, 10:15 AM PST.... etc at a constant interval of 15 Min. I am wondering if there is any Time datatype available for this kind of data? I need to store them as 11:00 AM PST, 11:15 AM PST, 11:30 AM PST, 11:45 PM PST, 12:00 PM PST, 12:15 PM PST, 12:30 PST, 12:45 PM PST, 01...

Best way to Sort-n-Concatenate 5 columns

!!! WARNING !!! Dearest SQL expert, please keep reading before to start to scream. this uber-denormalized table structure is obtained after apply some combinatories-sugar upon a nicely normalized set of data : ). I'm avoiding to renormalize this resultset because I want to keep simple the complete process (also this...

Cross Join 'n' times a table

It is possible to write a generic function/procedure/select/somethingElse to cross-join a table against himself 'n' times? (yes, 'n' is a given parameter : ) How would you do it? Example Having this table: Value ------- 1 2 3 cross join it 2 times, would return: Value | Value ------------------ 1 1 1 ...

Monolog conversations in SQL Service Broker 2008

Hi, I have a scenario in which I need to process(in SQL Server) messages being delivered as .xml files in a folder in real time. I started investigating SQL Service Broker for my queuing needs. Basically, I want the Service Broker to pick up my .xml files and place them in a queue as they arrive in the folder. But, SQL Service Broker...

best sql server client tool and refresh managment studio edit window ?

After using other gui tools for databases like oracle sql developer , plsql editor ..., I am not quite comfortable with sql server management studio,so I want to ask: Is there any better client tools for sql server? In management studio ,if I've already opened edit window, how to refresh the data in the window ? ...

Efficiency of checking for null varbinary(max) column ?

Using SQL Server 2008. Example table : CREATE table dbo.blobtest (id int primary key not null, name nvarchar(200) not null, data varbinary(max) null) Example query : select id, name, cast((case when data is null then 0 else 1 end) as bit) as DataExists from dbo.blobtest Now, the query needs to return a "DataExists" column, t...

How to create a conditional measure in SQL Server 2008 Analysis services

Hi there I am not sure if the title has the correct terms, I have a developer and am very new to cubes. I have a cube which has data associated to materials that are broken down into chemical compounds. For example a rock material has 10% of this chemical and 10% of that chemical, etc. Samples are taken daily and sample is a dimens...