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
 Transact-SQL (2000)
 HELP on inserting values in a SQL TABLE.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-12-03 : 07:34:00
Mathieu writes "Can someone give me an example where an insert statement will work please.
I do not know how to insert values appropriately into the following table:
CREATE TABLE [dbo].[tbl_user_information] (
[Id] [int] IDENTITY (1, 1) NOT NULL ,
[UserName] [varchar] (15) NOT NULL ,
[Password] varchar(10) Not Null,
[FirstName] [varchar] (255) NULL ,
[LastName] [varchar] (255) NULL ,
[Email] [varchar] (255) NULL ,
[Gender] [varchar] (1) NULL,
[Country] [varchar] (255) NULL ,
[LogCount] int Not Null Constraint DF_tbl_user_information_LogCount Default (1),
[CreateDate] datetime Not Null Constraint DF_tbl_user_information_CreateDate Default (getdate()),
[LastDate] datetime Not Null Constraint DF_tbl_user_information_LastDate Default (getdate()),
[IP] [char] (15) NULL

)
GO

Alter Table dbo.tbl_user_information Add Constraint
PK_tbl_user_information Primary Key Nonclustered
(
Id
)
Go

Alter Table dbo.tbl_user_information Add Constraint
IX_tbl_user_information Unique Nonclustered
(
UserName
)
Go"

nr
SQLTeam MVY

12543 Posts

Posted - 2002-12-03 : 07:41:23
insert tbl_user_information
(
UserName ,
Password ,
....
)
select
'myname' ,
'mypassword' ,
...


numbers without the quotes
dates as '20021202 11:05:00' or '20021202'
(your dates and numbers you can exclude from the insert list as they will default).



==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -