Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SMO Transfering specific rows from specific tables? Expand / Collapse
Author
Message
Posted Friday, May 20, 2011 3:36 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Yesterday @ 10:42 AM
Points: 49, Visits: 188
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?
Post #1112784
Posted Monday, May 23, 2011 3:45 PM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Monday, April 07, 2014 2:27 PM
Points: 460, Visits: 257
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

Post #1113668
Posted Monday, May 23, 2011 4:26 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Yesterday @ 10:42 AM
Points: 49, Visits: 188
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.
Post #1113684
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse