.net - Using SqlBulkCopy, how do I insert data into a table in a non-default database schema? -


i need insert data table in schema named staging using sqlbulkcopy.

it appears api allows set target table name using destinationtablename property.

how accomplish this? possible?

while api not provide explicit interface set destination schema, can stuff 2- or 3-part qualified table name destinationtablename property so:

b.destinationtablename = string.format("[{0}].[{1}]", schemaname, tablename); 

or

b.destinationtablename =     string.format("[{0}].[{1}].[{2}]", databasename, schemaname, tablename); 

given bulk insert has supported fully-qualified table name, seems big oversight separate components never made api.

moreover, appears destinationtablename output bulk insert statement, property may vulnerable sql injection. if you're getting information user @ point, make sure sanitize input before running operation.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -