|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 11:59 AM
Points: 7,076,
Visits: 7,115
|
|
Comments posted to this topic are about the item Table Variables
Tom Que conclure à la fin de tous mes longs propos? C'est que les préjugés sont la raison des sots. (Voltaire, 1756)
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 4:40 AM
Points: 2,198,
Visits: 4,148
|
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 4:24 AM
Points: 1,158,
Visits: 642
|
|
| Strange question if you ask me...
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: 2 days ago @ 3:44 PM
Points: 1,786,
Visits: 3,323
|
|
Aaaaarg!!! Got it wrong because of the unclustered index options.
I know that SQL Server enforces unique constraints by creating unique indexs, but I wasn't sure if this was what the author meant.
A minor detail; You probably mean ROGUIDCOL, not ROWGUID.
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 10:15 AM
Points: 1,869,
Visits: 1,426
|
|
Very good question! IgorMi
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Tuesday, April 23, 2013 8:54 AM
Points: 1,270,
Visits: 205
|
|
Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64) Apr 2 2010 15:48:46 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.0 <X64> (Build 6002: Service Pack 2)
DECLARE @t TABLE (id INT IDENTITY, id1 INT CHECK (id>id1))
Msg 8141, Level 16, State 0, Line 1 Column CHECK constraint for column 'id1' references another column, table '@t'.
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 6:22 AM
Points: 1,474,
Visits: 2,341
|
|
Nils Gustav Stråbø (10/19/2012) Aaaaarg!!! Got it wrong because of the unclustered index options.
I know that SQL Server enforces unique constraints by creating unique indexs, but I wasn't sure if this was what the author meant.
Ditto. Grr. 
Equally, the PK can be nonclustered. But I was thinking along the lines of explicity created indexes when I answered.
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: 2 days ago @ 3:44 PM
Points: 1,786,
Visits: 3,323
|
|
ako58 (10/19/2012) Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64) Apr 2 2010 15:48:46 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.0 <X64> (Build 6002: Service Pack 2)
DECLARE @t TABLE (id INT IDENTITY, id1 INT CHECK (id>id1))
Msg 8141, Level 16, State 0, Line 1 Column CHECK constraint for column 'id1' references another column, table '@t'. you need to declare the check constraint separately
DECLARE @t TABLE (id INT IDENTITY, id1 INT, CHECK (id>id1)) The error you got applies to normal and temporary tables aswell, so it is not a limitation on table variables. the following will also fail with the same error message.
create TABLE t(id INT IDENTITY, id1 INT CHECK (id>id1))
create TABLE #t(id INT IDENTITY, id1 INT CHECK (id>id1))
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 10:15 AM
Points: 1,869,
Visits: 1,426
|
|
Nils Gustav Stråbø (10/19/2012) Aaaaarg!!! Got it wrong because of the unclustered index options.
I know that SQL Server enforces unique constraints by creating unique indexs, but I wasn't sure if this was what the author meant.
A minor detail; You probably mean ROGUIDCOL, not ROWGUID.
declare @tabela table (id int not null, val1 varchar(20), val2 varchar(20), unique(val1,val2), primary key nonclustered(id,val1) )
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 10:33 AM
Points: 10,989,
Visits: 10,529
|
|
I found this a good and quite straightforward question (though it is SQL Server 2012 not SQL Server 2011).
Paul White SQL Server MVP SQLblog.com @SQL_Kiwi
|
|
|
|