Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
wak_fdb
Starting Member
2 Posts |
Posted - 2011-06-30 : 14:55:24
|
| Hello all,I have some pipe-delimited text data that I am importing into my SQL Server using the BULK INSERT command. One of the fields is DateTime in the format 'YYYYMMDD'. While the rows with valid date data import correctly, certain rows have '00000000' which causes an error message.Is there a way to do a conditional with the BULK INSERT? For example if it encounters a DateTime of '00000000', can I have it automatically change that value to null?Thanks. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2011-06-30 : 15:10:36
|
You can BULK INSERT into a staging table first, validate all columns and the move from staging table to production table.That's the appropriate thing to do.Lesson #1: Never trust users. Always verify. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
wak_fdb
Starting Member
2 Posts |
Posted - 2011-07-01 : 07:52:22
|
| Thanks. That sounds like a workable idea. I have been told that Oracle lets you do a "nullif 0" when you are creating and importing the tables. I suppose SQL Server doesn't have that. |
 |
|
|
|
|
|