J
JoeSchmoe115
Guest
If you look at this Microsoft Documentation article:
https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlbulkcopy?redirectedfrom=MSDN&view=netframework-4.5.2
in the Remarks section it says:
SqlBulkCopy will fail when bulk loading a DataTable column of type SqlDateTime into a SQL Server column whose type is one of the date/time types added in SQL Server 2008.
I am not observing this behavior (failure) and would like to know whether this documentation is possibly obsolete and SqlBulkCopy has been updated to support these data types.
More details on what I do:
Everything just works. I get no failures. I even tried passing "01/01/0001" date (outside of the range for SQL datetimetype) in the DataTable and it gets saved as such in database.
I did find this 8 years old SO post: How can I set column type when using SqlBulkCopy to insert into a sql_variant column but I am not using sql_variant and nothing fails in my case.
Can anyone clarify what Microsoft documentation I quoted mean?
If there is a better group to post this question - please let me know
Continue reading...
https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlbulkcopy?redirectedfrom=MSDN&view=netframework-4.5.2
in the Remarks section it says:
SqlBulkCopy will fail when bulk loading a DataTable column of type SqlDateTime into a SQL Server column whose type is one of the date/time types added in SQL Server 2008.
I am not observing this behavior (failure) and would like to know whether this documentation is possibly obsolete and SqlBulkCopy has been updated to support these data types.
More details on what I do:
- I create DataTable as a source for SqlBulkCopy. The DataTable column is of type System.DateTime.
- Target column in database table is of type datetime2.
- I use .Net 4.5 and SQL Server 2016 SP1
Everything just works. I get no failures. I even tried passing "01/01/0001" date (outside of the range for SQL datetimetype) in the DataTable and it gets saved as such in database.
I did find this 8 years old SO post: How can I set column type when using SqlBulkCopy to insert into a sql_variant column but I am not using sql_variant and nothing fails in my case.
Can anyone clarify what Microsoft documentation I quoted mean?
If there is a better group to post this question - please let me know
Continue reading...