November 23, 2010 at 5:46 am
Hi all,
I need to insert one row in table.but it has more than 35 columns.
I have datatable it has all the columns with value(only one row)
so is there any way to pass the whole datatable to db without specifying columns and without use bulk copy(because datatable has only one row)
November 23, 2010 at 5:49 am
Like this?
INSERT INTO x
(
...
)
SELECT ...
FROM y
... = column names 😀
November 23, 2010 at 6:24 am
With only a single row to send, I'd suggest just creating a procedure or parameterized query that lists the columns and send that over. That really is the better approach. Absolutely.
However, if you want to, you can use table-valued parameters. It's outlined here.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
November 23, 2010 at 11:02 pm
Thank you very much.
I get inserted successfully through the method which u specify
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply