SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Use of Key Column


Use of Key Column

Author
Message
Mahmood.BilalB
Mahmood.BilalB
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1111 Visits: 163
Comments posted to this topic are about the item Use of Key Column
Danny Ocean
Danny Ocean
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3528 Visits: 1549
In this question, first unique constraint pull my attention, But suddenly i look at "max" keyword.
due to that i got it right.
Good question thanks.:-)

Thanks
Vinay Kumar
-----------------------------------------------------------------
Keep Learning - Keep Growing !!!
www.GrowWithSql.com
kapil_kk
kapil_kk
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11255 Visits: 2778
Good question Mahmood :-)

_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Neeraj Prasad Sharma
Neeraj Prasad Sharma
SSC Eights!
SSC Eights! (885 reputation)SSC Eights! (885 reputation)SSC Eights! (885 reputation)SSC Eights! (885 reputation)SSC Eights! (885 reputation)SSC Eights! (885 reputation)SSC Eights! (885 reputation)SSC Eights! (885 reputation)

Group: General Forum Members
Points: 885 Visits: 675
Nice one.

Neeraj Prasad Sharma
Sql Server Tutorials
tehmina_114
tehmina_114
SSC Journeyman
SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)SSC Journeyman (86 reputation)

Group: General Forum Members
Points: 86 Visits: 26
informative question :-)
ITGuy268
ITGuy268
Old Hand
Old Hand (318 reputation)Old Hand (318 reputation)Old Hand (318 reputation)Old Hand (318 reputation)Old Hand (318 reputation)Old Hand (318 reputation)Old Hand (318 reputation)Old Hand (318 reputation)

Group: General Forum Members
Points: 318 Visits: 286
Good question +1 thanks Smile

MCTS | MCITP | Microsoft SQL Server 2008 Administration & Development
MCSA | MCSE | Business Intelligence SQL Server 2012
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSC-Dedicated
SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)

Group: General Forum Members
Points: 37604 Visits: 7740
Interesting question, thanks.

____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
manik_anu
manik_anu
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1230 Visits: 345
CREATE TABLE #temp
(
ID int PRIMARY KEY,
Name varchar(900)
CONSTRAINT UN_Name UNIQUE(Name)
);

The #temp table created with 900 bytes, but

CREATE TABLE #temp
(
ID int PRIMARY KEY,
Name varchar(1000)
CONSTRAINT UN_Name UNIQUE(Name)
);

if i try to create table with 1000 bytes, it shows the below error... But the temp table created and 3 rows were inserted.... Then what is the maximum length can we use? Please any one give explanation for this....

Warning! The maximum key length is 900 bytes. The index 'UN_Name' has maximum length of 1000 bytes. For some combination of large values, the insert/update operation will fail.

nice question....

Manik
You cannot get to the top by sitting on your bottom.
Dineshbabu
Dineshbabu
SSCommitted
SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)

Group: General Forum Members
Points: 1962 Visits: 569
Good question .. But explanation is slightly wrong.

Table is not created because varchar(MAX) is not allowed type for use as a key column in an index. This doesn't mean you cannot create index on column length is more than 900 bytes. You can create index on column even with length of varchar(8000). Just we will receive warning message.

Warning! The maximum key length is 900 bytes. The index 'UN_Name' has maximum length of 8000 bytes. For some combination of large values, the insert/update operation will fail.


IF you try to insert/update a value of more than 900 bytes then error will be raised and insert fails.

AS well as if you try to create a index on the column with CHAR(8000), this time you will recieve error on index creation itself because length of CHAR columns are fixed.

--
Dineshbabu
Desire to learn new things..
pchirags
pchirags
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: General Forum Members
Points: 3405 Visits: 617
Nice Question..
Thanks..
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search