SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SMO Transfering specific rows from specific tables?


SMO Transfering specific rows from specific tables?

Author
Message
johnzabroski
johnzabroski
Old Hand
Old Hand (387 reputation)Old Hand (387 reputation)Old Hand (387 reputation)Old Hand (387 reputation)Old Hand (387 reputation)Old Hand (387 reputation)Old Hand (387 reputation)Old Hand (387 reputation)

Group: General Forum Members
Points: 387 Visits: 191
In many situations, I just want to grab one or two rows from a table and script out the inserts. It would be nice if SMO did this for me automatically, including handling whether to generate "set identity_insert [schema].[table_name] on/off" lines.

I can't use the traditional way to dump table data:

ScriptingOptions.ScriptData = true

This option scripts out EVERYTHING. I just want one row, e.g. the row where a PK equals 0.

What's the best way to do this?
patricklambin
patricklambin
SSCarpal Tunnel
SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)

Group: General Forum Members
Points: 4750 Visits: 1241
Hello,

I am sorry , but , with my poor english, i am not sure to have fully understood your question.
I am using SMO since the release of SQL Server 2005 SP2 ( before SMO was often incomplete or with bugs ).
To get the results of a query ( SElECT mainly ) , i am relying on the SqlClient namespace ( so .Net Framework ) and for the SqlConnection necessary to create a SqlCommand , i get it from the SqlConnectionObject property of Server.ConnectionContext.

I have some doubts to have understood your hypothesis about primary keys with a value of 0. Please, could you tell us whether you want to create a primary key on a column having already values ? If yes, you cannot create a primary key on a column if you have several rows with the same value.
But, it is possible that i have not understood your question ( usually, i can translate english in french, but french into english , really difficult for me and i hope you will excuse me ).

Have a nice day
johnzabroski
johnzabroski
Old Hand
Old Hand (387 reputation)Old Hand (387 reputation)Old Hand (387 reputation)Old Hand (387 reputation)Old Hand (387 reputation)Old Hand (387 reputation)Old Hand (387 reputation)Old Hand (387 reputation)

Group: General Forum Members
Points: 387 Visits: 191
It's ok. I solved the problem by avoiding it. Using SMO was an experiment and a bad idea for this problem. Wrong tool for the job.
vckumar2004
vckumar2004
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 239
Hi, Can you provide the script for insert script for all table data? Thanks
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search