469,917 Members | 1,789 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

SQL Server 2005

Please, how to create a table with SQL statement in SQL Server 2005 including an ID number for the first field as well as an incrementation?

Thank you.
Jul 20 '07 #1
1 807
[HTML]GO
CREATE TABLE [dbo].[MyTable](
[id] [uniqueidentifier] NOT NULL,
[AgentID] [int] NOT NULL,
[BusinessName] [varchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Address1] [varchar](30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Address2] [varchar](30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[City] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[State] [char](2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Zip] [varchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[County] [varchar](15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
CONSTRAINT [PK_ID] PRIMARY KEY NONCLUSTERED
(
[AgentID] ASC
) ON [PRIMARY]
) ON [PRIMARY][/HTML]
This SQL statement should give you an idea of what to do. The uniqueIdentifier will automatically increase by one for each record. Just change the table name and the columns names and their datatypes and run the query. If you need to modify the table after it is created just change the CREATE to ALTER.
Good luck
Jul 20 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

17 posts views Thread by Danieltbt05 | last post: by
10 posts views Thread by amjad | last post: by
3 posts views Thread by Lee T. Hawkins | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.