Batman
Batman

Reputation: 6353

SQL Insert Statement with Null?

Im trying to insert data into a table which has an attribute that can be Null. However, im not sure how to accomplish this with my SQL statements.

INSERT INTO [dbo].[INVOICE]
           ([INV_ID]
           ,[EMP_ID]
           ,[WAR_ID]
           ,[REP_ID]
           ,[FIN_ID]
           ,[INV_DATE]
           ,[INV_PRICE])
     VALUES
(5655,8,1**,,**3,'7/5/2000',75880),
(9749,1,1**,,**1,'11/26/2002',58881),
(9909,3,1**,187,**3,'12/27/2012',64859);

Upvotes: 0

Views: 1252

Answers (2)

Shamis Shukoor
Shamis Shukoor

Reputation: 2515

INSERT INTO [dbo].[INVOICE]
           ([INV_ID]
           ,[EMP_ID]
           ,[WAR_ID]
           ,[REP_ID]
           ,[FIN_ID]
           ,[INV_DATE]
           ,[INV_PRICE])
     VALUES
(5655,8,1,NULL,3,'7/5/2000',75880),
(9749,1,1,NULL,1,'11/26/2002',58881),
(9909,3,1,NULL,3,'12/27/2012',64859);

You could use NULL to represent null

Upvotes: 1

Raam
Raam

Reputation: 10876

INSERT INTO [dbo].[INVOICE]
           ([INV_ID]
           ,[EMP_ID]
           ,[WAR_ID]
           ,[REP_ID]
           ,[FIN_ID]
           ,[INV_DATE]
           ,[INV_PRICE])
     VALUES (5655,8,1**,NULL,**3,'7/5/2000',75880), (9749,1,1**,NULL,**1,'11/26/2002',58881), (9909,3,1**,187,**3,'12/27/2012',64859);

Upvotes: 3

Related Questions