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.
Author |
Topic |
danasegarane76
Posting Yak Master
242 Posts |
Posted - 2007-05-22 : 01:34:10
|
Dear All, How can I add a Default value and Set the Field as identy in a create table query statementThnks Dana |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-05-22 : 01:37:28
|
[code]-- creating identity columncreate table xyz( col1 int identity(1,1))-- creating default valuecreate table pqr(col1 int default(0))[/code]or you can create default using CREATE DEFAULT and bind it later using sp_bindefault.But, you can't have both identity and default on same column at a time.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
danasegarane76
Posting Yak Master
242 Posts |
Posted - 2007-05-22 : 01:50:29
|
Dear Harsh, Thanks for Your Reply.How can combine both these? |
 |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-05-22 : 02:01:44
|
I already told you can't have default on identity column.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
danasegarane76
Posting Yak Master
242 Posts |
Posted - 2007-05-22 : 02:34:28
|
Thanks Harsh, How to set a string value as a Default value ? |
 |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-05-22 : 02:40:21
|
Similar to what I shown for INT column.create table xyz( col1 varchar(50) default 'MyDefault') Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
danasegarane76
Posting Yak Master
242 Posts |
Posted - 2007-05-22 : 04:57:26
|
Thanks Harsh :) |
 |
|
|
|
|