Click here to Skip to main content
       

Database

 
GeneralRe: Combining Data From Temp Tables PinmemberJörgen Andersson28-Jan-13 22:28 
Question[VB.net+ADO.net]how can combobox 1 control the result of combobox2 PinmemberAchilles8428-Jan-13 8:20 
AnswerRe: [VB.net+ADO.net]how can combobox 1 control the result of combobox2 PinmemberAchilles8430-Jan-13 3:47 
QuestionSMO Retrieve Table Record Pinmembersavbace28-Jan-13 2:31 
AnswerRe: SMO Retrieve Table Record PinmvpSandeep Mewara28-Jan-13 2:42 
AnswerRe: SMO Retrieve Table Record Pinmembersavbace28-Jan-13 2:55 
QuestionRe: SMO Retrieve Table Record PinmvpEddy Vluggen28-Jan-13 3:21 
AnswerRe: SMO Retrieve Table Record PinmvpSandeep Mewara28-Jan-13 3:22 
Here, a similar question[^] discussed.
 
It says: Have a look at SMO's Scripter class[^]. The following basic sample works for me:
using System.Data.SqlClient;
using System.IO;
using System.Text;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
 
namespace SqlExporter
{
class Program
{
static void Main(string[] args)
{
    var server = new Server(new ServerConnection {ConnectionString = new SqlConnectionStringBuilder {DataSource = @"LOCALHOST\SQLEXPRESS", IntegratedSecurity = true}.ToString()});
    server.ConnectionContext.Connect();
    var database = server.Databases["MyDatabase"];
    var output = new StringBuilder();
 
    foreach (Table table in database.Tables)
    {
        var scripter = new Scripter(server) {Options = {ScriptData = true}};
        var script = scripter.EnumScript(new SqlSmoObject[] {table});
        foreach (var line in script)
            output.AppendLine(line);
    }
    File.WriteAllText(@"D:\MyDatabase.sql", output.ToString());
}
}
}
Sandeep Mewara
Microsoft ASP.NET MVP 2012 & 2013
 

[My Latest Article(s)]:
How to extend a WPF Textbox to Custom Picker
Server side Delimiters in ASP.NET

AnswerRe: SMO Retrieve Table Record Pinmembersavbace28-Jan-13 3:40 
Questionhow can reporting in this Situation [modified] Pinmemberkarimkpg26-Jan-13 2:38 
AnswerRe: how can reporting in this Situation PinmvpSandeep Mewara26-Jan-13 6:02 
QuestionQuery to concatenate multiple rows based on sequence in results set PinmemberAlex Lush24-Jan-13 22:43 
AnswerRe: Query to concatenate multiple rows based on sequence in results set PinmvpEddy Vluggen25-Jan-13 1:51 
AnswerRe: Query to concatenate multiple rows based on sequence in results set PinmemberShameel25-Jan-13 3:20 
GeneralRe: Query to concatenate multiple rows based on sequence in results set PinmemberAlex Lush25-Jan-13 3:30 
AnswerRe: Query to concatenate multiple rows based on sequence in results set Pinmembermmccarth25-Jan-13 5:21 
QuestionSyntax error (Missing Operator) in Query expression ':0:1 PinmemberIgaBaro23-Jan-13 14:40 
AnswerRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberMycroft Holmes23-Jan-13 15:02 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberIgaBaro23-Jan-13 15:25 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberPIEBALDconsult23-Jan-13 15:37 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberIgaBaro23-Jan-13 16:16 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberPIEBALDconsult23-Jan-13 16:26 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberIgaBaro23-Jan-13 16:58 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmemberPIEBALDconsult23-Jan-13 16:59 
AnswerRe: Syntax error (Missing Operator) in Query expression ':0:1 PinmvpRichard MacCutchan23-Jan-13 23:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.141015.1 | Last Updated 21 Oct 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid