|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Wednesday, August 29, 2012 2:08 PM
Points: 74,
Visits: 237
|
|
Hi! Sorry if this is a really basic question, but any help is definitely appreciated!
I'm loading a bunch of csv files into a table, and want to create a package using dts wizard & SSBIDS to run this a few times a week as files come in.
The files I'm importing are missing a RowID, which I would like to create during the upload process and be able to use as a primary key. ...but as I don't have a source row for it, I'm not really sure how to map nothing to something in the destination table.
Any ideas?
Thanks!
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Friday, February 22, 2013 12:03 AM
Points: 2,555,
Visits: 2,587
|
|
Does the RowID needs to be arbitrary? If not, then you can add an IDENTITY column to your destination table and leave the complexity for SQL Server to handle.
--Ramesh
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Sunday, November 04, 2012 12:23 PM
Points: 2,087,
Visits: 3,932
|
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Friday, February 22, 2013 12:03 AM
Points: 2,555,
Visits: 2,587
|
|
Florian Reischl (3/17/2009) If you don't use an IDENTITY column you can import the date into a temp table and use the following statement to add an incremental id:
This should work, but it does not give the sequence ids according to the order of the input rows.
--Ramesh
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Wednesday, August 29, 2012 2:08 PM
Points: 74,
Visits: 237
|
|
Maybe I'm misunderstanding your suggestion - but I just tried to follow it, and was unsuccessful.
I named my RowID column [IDENTITY] (SQL added the brackets automatically, which I guessed meant I was on the right track...)
I set it to my primary key, so it is not allowed to contain NULL values.
Then when I reran the bulk load, I got the same error message, but with RowID replaced with IDENTITY: An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Cannot insert the value NULL into column 'IDENTITY', table 'PWS_BKM.dbo.tblTradeHistory'; column does not allow nulls. INSERT fails.".
Am I not doing this right?
Thanks!
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 4:20 PM
Points: 6,998,
Visits: 13,947
|
|
Don't NAME it "identity" - MAKE it an identity column. If you're using the UI - look in the properties of the column (identity specification section).
---------------------------------------------------------------------------------- Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Friday, February 22, 2013 12:03 AM
Points: 2,555,
Visits: 2,587
|
|
You have to explicitly specify that you want the value of IDENTITY column to be generated by SQL Server. This can be set by un-checking the "Keep Identity" property of OLE DB Destination component in Data Flow Task.
--Ramesh
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Wednesday, August 29, 2012 2:08 PM
Points: 74,
Visits: 237
|
|
Great - I had to uncheck the box labeled "Enable Identity Insert" in the Edit Mappings part of the OLEDB Destination part of the wizard.
Thanks!
|
|
|
|