Click here to Skip to main content
15,903,385 members
Home / Discussions / Database
   

Database

 
Questionhow to cast real data type in sql server 2005 Pin
Auf Klarung2-Jan-13 22:55
Auf Klarung2-Jan-13 22:55 
QuestionRe: how to cast real data type in sql server 2005 Pin
Eddy Vluggen4-Jan-13 22:52
professionalEddy Vluggen4-Jan-13 22:52 
QuestionSql server like clause Pin
rubonkumar28-Dec-12 4:44
rubonkumar28-Dec-12 4:44 
AnswerRe: Sql server like clause Pin
Richard MacCutchan28-Dec-12 6:05
mveRichard MacCutchan28-Dec-12 6:05 
AnswerRe: Sql server like clause Pin
PIEBALDconsult28-Dec-12 6:38
mvePIEBALDconsult28-Dec-12 6:38 
GeneralRe: Sql server like clause Pin
Mike Meinz28-Dec-12 6:49
Mike Meinz28-Dec-12 6:49 
GeneralRe: Sql server like clause Pin
rubonkumar28-Dec-12 19:08
rubonkumar28-Dec-12 19:08 
AnswerRe: Sql server like clause Pin
rajarao3044-Jan-13 0:50
rajarao3044-Jan-13 0:50 
QuestionDatabase design question Pin
David Crow27-Dec-12 15:22
David Crow27-Dec-12 15:22 
AnswerRe: Database design question Pin
PIEBALDconsult27-Dec-12 15:52
mvePIEBALDconsult27-Dec-12 15:52 
AnswerRe: Database design question Pin
jschell28-Dec-12 10:16
jschell28-Dec-12 10:16 
GeneralRe: Database design question Pin
PIEBALDconsult28-Dec-12 14:42
mvePIEBALDconsult28-Dec-12 14:42 
GeneralRe: Database design question Pin
jschell30-Dec-12 8:28
jschell30-Dec-12 8:28 
AnswerRe: Database design question Pin
Mycroft Holmes28-Dec-12 11:05
professionalMycroft Holmes28-Dec-12 11:05 
QuestionImporting of Huge fixed width text file in sql server table Pin
ibrahim sharief27-Dec-12 9:24
ibrahim sharief27-Dec-12 9:24 
AnswerRe: Importing of Huge fixed width text file in sql server table Pin
PIEBALDconsult27-Dec-12 14:08
mvePIEBALDconsult27-Dec-12 14:08 
AnswerRe: Importing of Huge fixed width text file in sql server table Pin
Deepak Kr130-Dec-12 20:29
Deepak Kr130-Dec-12 20:29 
AnswerRe: Importing of Huge fixed width text file in sql server table Pin
jschell31-Dec-12 9:14
jschell31-Dec-12 9:14 
Questionshow Sum(Balance) as ob on Rows Header and add next rows balance in ob Pin
hadeed147227-Dec-12 6:52
hadeed147227-Dec-12 6:52 
AnswerRe: show Sum(Balance) as ob on Rows Header and add next rows balance in ob Pin
Corporal Agarn27-Dec-12 7:53
professionalCorporal Agarn27-Dec-12 7:53 
GeneralRe: show Sum(Balance) as ob on Rows Header and add next rows balance in ob Pin
hadeed147227-Dec-12 8:03
hadeed147227-Dec-12 8:03 
QuestionSQL BulkCopy using IDataReader - how can you cast the fields? Pin
Allan Watkins26-Dec-12 19:12
Allan Watkins26-Dec-12 19:12 
I'm looking for a method/example/pseudo-code of importing a CSV file into a SQL Server table with several requirements:
1) I do not know the quantity of columns, column header nor data type of each column prior to the program running. Along with the header fields, I have another file which describes the type and size of each column (like integer, decimal or string) and I can already create the destination table based on this input.
2) Because I don't know the format of the input table before running the program (i.e. the input table changes every time), I can't create a class specifically designed to describe the contents of each record from the CSV file.
3) I already have a method working where a DataTable gets fully populated and the SQLBulkCopy variable uses the .WriteToServer() method to insert all of the records. HOWEVER, there's a problem when the source file gets too large (over 500mb or so) and the result is an OutOfMemory exception.
4) The AdHocGeek has a partial solution which works with strings only but doesn't address integers, decimals, dates, et.al.

The problem is that I can't see a way to use an IDataReader into a complex (i.e. many field types) table on the fly. I've added the .ColumnMappings() method to determine the name of the columns with which to map the input columns into the destination SQL Server table. When the application is run however, it gets an error indicating "The given value of type String from the data source cannot be converted to type decimal of the specified target column".

I can't determine why the DataTable works and the DataReader doesn't and can't find any examples to prove otherwise.

Any ideas or examples would be appreciated.
AnswerRe: SQL BulkCopy using IDataReader - how can you cast the fields? Pin
Mycroft Holmes26-Dec-12 20:32
professionalMycroft Holmes26-Dec-12 20:32 
GeneralRe: SQL BulkCopy using IDataReader - how can you cast the fields? Pin
AllanW1111127-Dec-12 6:02
AllanW1111127-Dec-12 6:02 
AnswerRe: SQL BulkCopy using IDataReader - how can you cast the fields? Pin
PIEBALDconsult27-Dec-12 8:48
mvePIEBALDconsult27-Dec-12 8:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.