Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Greetings!I am struggling to create a primary key made of 4 columns in one of my declared table variables.What is the exact syntax for doing this?
TG
Master Smack Fu Yak Hacker
6065 Posts
Posted - 2006-03-10 : 09:58:16
I'm not sure of the benefit you'll get from this but it's the same as a normal table...
declare @tb table (i1 int ,i2 int ,primary key (i1,i2))insert @tb (i1,i2)select 1,1 union allselect 1,2 --union all select 1,2 /*generate a pk violation*/
Be One with the OptimizerTG
Antonio
Posting Yak Master
168 Posts
Posted - 2006-03-10 : 10:02:46
quote:Originally posted by TG I'm not sure of the benefit you'll get from this but it's the same as a normal table...
declare @tb table (i1 int ,i2 int ,primary key (i1,i2))insert @tb (i1,i2)select 1,1 union allselect 1,2 --union all select 1,2 /*generate a pk violation*/