Results 1 to 8 of 8

Thread: (Resolved) Insert into a table with an identity column

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    (Resolved) Insert into a table with an identity column

    I am trying to insert some data into a SQL server that uses a uniqueidentifier for the invId field. My SQL statement doesn't include that field so I assumed that the field would just increment automaticaly as it does in Access. However I get an error that I can not insert Nulls into my InvId field. I did find something on the net about IDENTITY_INSERT but I can't seem to get it to work.

    Here is my SQL:
    Code:
    INSERT INTO Reports.dbo.tblMeInventory( 
    	invId IDENTITY,
    	CategoryCode, 
    	ItemCode, 
    	UnitCode, 
    	ItemCount, 
    	UserName, 
    	DateStamp )
    SELECT
    	StoreItems.CategoryCode, 
    	StoreItems.ItemCode, 
    	StoreItems.UnitCode, 
    	0 AS ItemCount, 
    	'' AS UserName, 
    	'' AS DateStamp
    FROM 
    	lubeShop.dbo.StoreItems
    WHERE(
    	((StoreItems.StoreID)<>999) AND 
    	((StoreItems.IsDeleted)=0))
    ORDER BY 
    	StoreItems.StoreID, 
    	StoreItems.CategoryCode, 
    	StoreItems.ItemCode
    Oops I meant to post this in the database forum. It is a VB related question but I think it should have probably been posted there instead of here.
    Last edited by FastEddie; Jul 30th, 2007 at 10:57 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width