|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 10:54 AM
Points: 7,112,
Visits: 7,186
|
|
Comments posted to this topic are about the item Table Variables
Tom Is minic a gheibheann béal oscailte dorn dúnta. Is minig a cheapas beul fosgailte dòrn dùinte.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 6:38 AM
Points: 2,231,
Visits: 4,207
|
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 4:24 AM
Points: 1,161,
Visits: 642
|
|
| Strange question if you ask me...
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: 2 days ago @ 8:52 AM
Points: 1,788,
Visits: 3,327
|
|
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: Yesterday @ 9:56 AM
Points: 1,882,
Visits: 1,459
|
|
Very good question! IgorMi
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Tuesday, April 23, 2013 8:54 AM
Points: 1,275,
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: Monday, May 20, 2013 1:53 AM
Points: 1,474,
Visits: 2,342
|
|
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 @ 8:52 AM
Points: 1,788,
Visits: 3,327
|
|
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: Yesterday @ 9:56 AM
Points: 1,882,
Visits: 1,459
|
|
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: Today @ 1:03 AM
Points: 10,990,
Visits: 10,543
|
|
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
|
|
|
|