MS-SQL - Bulk Insert query
-
I have a .csv file with following column:
Col1,Col2
And the data table has one extra datetime column:
Col1,Col2,TimeStamp
While importing data using BULK INSERT from the CSV, is there a way to specify the value for the TimeStamp column too? (Timestamp would be same for all the newly imported rows)
Suhredayan
-
I have a .csv file with following column:
Col1,Col2
And the data table has one extra datetime column:
Col1,Col2,TimeStamp
While importing data using BULK INSERT from the CSV, is there a way to specify the value for the TimeStamp column too? (Timestamp would be same for all the newly imported rows)
Suhredayan
-
How about defining a default value for the column?
ALTER TABLE dbo.tablename ADD CONSTRAINT
DF_TimeStamp DEFAULT '20091218' FOR TimeStampBob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP
Ashfield wrote:
How about defining a default value for the column?
That may not work since the timestamp is same only per bulk insert. I do have a solution for this, wrap bulk insert inside a stored proc, and update the the timestamp from SP. But this would introduce few additional steps, was wondering if this can be avoided in case if BULK INSERT already has this feature. Thank you, Suhredayan