question

NarasimhaMedicharla avatar image
NarasimhaMedicharla asked

How to get Alter script using SMO

Iam genarating script of same table in two diffrent databases(like DB v1 and v2). And comparing the columns of one table to another table and add new columns and alter() method.. following is my code block DestServerNames.ConnectionContext.SqlExecutionModes = SqlExecutionModes.CaptureSql; foreach (Column objColumn in source.Columns) { if (!destination.Columns.Contains(objColumn.Name)) { destination.Columns.Add(new Column(destination, objColumn.Name, objColumn.DataType)); // destination.Refresh(); } } DestServerNames.Alter(); DestServerNames.Refresh(); // Iterate through the strings in the capture buffer and display the captured statements. StringBuilder sb = new StringBuilder(); foreach (string p_s in DestServerNames.ConnectionContext.CapturedSql.Text) { sb.AppendLine(p_s); } richTextBox1.Text = sb.ToString(); but in foreach loop iam getting only > USE [master] EXEC sys.sp_configure N'user options', 32 RECONFIGURE USE [master] EXEC sys.sp_configure N'user options', 32 RECONFIGURE So how to get Alter script of my table.....What is the wrong in above code...Please correct it. Thanks in advance Narasimha.M
smo
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.