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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Table Creation with Default Values

Author  Topic 

rajeshkumar77
Starting Member

46 Posts

Posted - 2001-12-16 : 02:43:19
hai
how to create a table in database thru query analyzer.
i have a default value for the field.
for ex.

create table emp (eno int);

for the above table how can i set the default value for eno field.

can anybody know this..please give me the sql query to create table with default values

Thanks in advance
Yours
Rajesh

VyasKN
SQL Server MVP & SQLTeam MVY

313 Posts

Posted - 2001-12-16 : 04:31:01
Rajesh, try this:

CREATE TABLE Emp (eno int DEFAULT 1)
GO

The above command sets a default value of 1 to eno column.

Instead you could try this, so that everytime you insert a row into Emp table, you get a new value for eno column.

CREATE TABLE Emp (eno int IDENTITY)
GO

For more information see BOL.
Vyas
[url]http://vyaskn.tripod.com[/url]

Go to Top of Page
   

- Advertisement -