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 |
|
rammohan
Posting Yak Master
212 Posts |
Posted - 2006-10-19 : 02:27:16
|
| hi, i wish to create a table which contain fields num,name. i want to maintain some default data in column name. so iwant to insert my default data say(ram,ramu1,ram2) in the column at the time of my table craetion. i written the code create table tab1(num int primary key,name char(20),insert into tab1(name) values(ram))but it is throwing some erroes.can u pls suggest me a way to deal this task.thanx in advance,rammohanOne can never consent to creep,when one feels an impulse to soarRAMMOHAN |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-10-19 : 02:35:26
|
| [code]CREATE TABLE tab1 ( num int IDENTITY (1, 1) NOT NULL PRIMARY KEY, name varchar(20) NOT NULL, keycol AS (name + convert(varchar, num)) )[/code]Peter LarssonHelsingborg, Sweden |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-10-19 : 03:17:15
|
you have to create the default constraint for itALTER TABLE dbo.Tab ADD CONSTRAINT DF_Tab_Name DEFAULT 'Ram' FOR NameGo -- Then Insert the values in the table.. Insert TabDEfault values Chiraghttp://chirikworld.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|