Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

In smo im trying to script each table out to a file. I can script each table to an array as shown:

 

 

Table[] tables = new Table[db.Tables.Count];

           db.Tables.CopyTo(tables, 0);

           SqlSmoObject[] smoObj = new SqlSmoObject[tables.Length];

           Array.Copy(tables, smoObj, tables.Length);

           Scripter scripter = new Scripter(s);
        
           StringCollection scriptsList = scripter.Script(smoObj);

           string[] scripts = new string[scriptsList.Count];
           scriptsList.CopyTo(scripts, 0);

 

i expected each array of the scripts array to have a table creation script, but no.

 

element 0 of the array contains the text:

 

SET ANSI_NULLS OFF

 

element 1 of the array contains the text:

 

SET QUOTED_IDENTIFIER ON

 

element 3 of the array contains the text:

 

CREATE TABLE [dbo].[_EXRATE02EuroZoneCurrencyRate](

[CurrencyCode] [char](3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,

[FixedExchangeRateAmt] [float] NOT NULL

) ON [PRIMARY]

 

 

this continues throughout the array. how am i supposed to find the end of one script and the beginning of another? will SET ANSI_NULLS OFF be at the beginning of each table script, if so i can create a new script each time i find that line.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...