How do I fetch multiple columns for use in a cursor loop?

Here is slightly modified version. Changes are noted as code commentary. BEGIN TRANSACTION declare @cnt int declare @test nvarchar(128) — variable to hold table name declare @tableName nvarchar(255) declare @cmd nvarchar(500) — local means the cursor name is private to this code — fast_forward enables some speed optimizations declare Tests cursor local fast_forward for SELECT … Read more

conditional unique constraint

Behold, the filtered index. From the documentation (emphasis mine): A filtered index is an optimized nonclustered index especially suited to cover queries that select from a well-defined subset of data. It uses a filter predicate to index a portion of rows in the table. A well-designed filtered index can improve query performance as well as … Read more

Warning: Null value is eliminated by an aggregate or other SET operation in Aqua Data Studio

You would mostly be using COUNT to summarize over a UID. Therefore COUNT([uid]) will produce the warning: Warning: Null value is eliminated by an aggregate or other SET operation. whilst being used with a left join, where the counted object does not exist. Using COUNT(*) in this case would also render incorrect results, as you … Read more

Using SQL Server 2008 and SQL Server 2005 and date time

A quick google points me to what looks like the solution. Open your EDMX in a file editor (or “open with…” in Visual Studio and select XML Editor). At the top you will find the storage model and it has an attribute ProviderManifestToken. This has should have the value 2008. Change that to 2005, recompile … Read more