December 16, 2010 at 7:55 pm
I'm parsing a text file into a C# DataTable then using SQLBulkCopy to populate a SQL Table
In C# I Parse a string into a DateTime value and set a 'Date' column row value to it
I also do the same for a 'Time' column
Now in the SQL Table the corresponding column is set to accept Date only - so result in the SQL table is as I expect I see only the Date
I cannot seem to find a way to do this with the SQL table to use only the Time portion - with different commands involving Time I can only get full DateTime or error ?
December 16, 2010 at 8:01 pm
If you don't mind, I'd like to ask a question first. Why are you separating the date and time? I would think it would make more sense to keep them together in same column as a datetime value.
December 17, 2010 at 6:07 am
My thoughts exactly but the people I'm doing this for insist on this way
December 17, 2010 at 6:25 am
Have you asked why and can you share their thought pattern here? Just insisting doesn't mean it is correct. I would hope that they would be open to other alternatives depend on what is being attempted.
The only real reason I could see for separating date and time would be in a data warehouse where you needed a separate time dimension.
December 17, 2010 at 7:29 am
So what happens to the target Time field in the SQL database after the Bulk Copy?
DECLARE @varTime AS Time(0)
Also, it shouldn't matter, but why not pull directy from the flat file?
A nod is as good as a wink to a blind bat.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply