Reputation: 5126
So data can be imported into SQL Server from .csv files. Import CSV file into SQL Server
I'm trying to use this to import test data into a database. So I want the dates to be up-to-date. Currently we use .sql files with getdate()
so after inserting the dates are all newly generated. But when inserting getdate()
with bulk insert from a .csv file it will just say 'getdate()'. The dates are only an example, I need different rows to be calculated differently. So one date might get 5 added to it, another 10.
Upvotes: 0
Views: 1406
Reputation: 726809
Although bulk insert does not let you specify function calls, you could work around the problem by changing your table definition: add default
constraint to your date
column, and do not insert anything into it through bulkinsert. This would ensure that SQL Server fills the column by calling getdate
:
ALTER TABLE MyTable ADD CONSTRAINT
DF_MyTable_MyDateColumn_GetDate DEFAULT GETDATE() FOR MyDateColumn
Upvotes: 1