Click here to Skip to main content
15,506,865 members
Home / Discussions / Database
   

Database

 
GeneralRe: Combining Data From Temp Tables Pin
Jörgen Andersson28-Jan-13 23:28
professionalJörgen Andersson28-Jan-13 23:28 
Question[VB.net+ADO.net]how can combobox 1 control the result of combobox2 Pin
Achilles8428-Jan-13 9:20
Achilles8428-Jan-13 9:20 
AnswerRe: [VB.net+ADO.net]how can combobox 1 control the result of combobox2 Pin
Achilles8430-Jan-13 4:47
Achilles8430-Jan-13 4:47 
QuestionSMO Retrieve Table Record Pin
savbace28-Jan-13 3:31
savbace28-Jan-13 3:31 
AnswerRe: SMO Retrieve Table Record Pin
Sandeep Mewara28-Jan-13 3:42
mveSandeep Mewara28-Jan-13 3:42 
AnswerRe: SMO Retrieve Table Record Pin
savbace28-Jan-13 3:55
savbace28-Jan-13 3:55 
QuestionRe: SMO Retrieve Table Record Pin
Eddy Vluggen28-Jan-13 4:21
professionalEddy Vluggen28-Jan-13 4:21 
AnswerRe: SMO Retrieve Table Record Pin
Sandeep Mewara28-Jan-13 4:22
mveSandeep Mewara28-Jan-13 4:22 
Here, a similar question[^] discussed.

It says: Have a look at SMO's Scripter class[^]. The following basic sample works for me:
C#
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 Pin
savbace28-Jan-13 4:40
savbace28-Jan-13 4:40 
Questionhow can reporting in this Situation Pin
karimkpg26-Jan-13 3:38
karimkpg26-Jan-13 3:38 
AnswerRe: how can reporting in this Situation Pin
Sandeep Mewara26-Jan-13 7:02
mveSandeep Mewara26-Jan-13 7:02 
QuestionQuery to concatenate multiple rows based on sequence in results set Pin
Alex Lush24-Jan-13 23:43
Alex Lush24-Jan-13 23:43 
AnswerRe: Query to concatenate multiple rows based on sequence in results set Pin
Eddy Vluggen25-Jan-13 2:51
professionalEddy Vluggen25-Jan-13 2:51 
AnswerRe: Query to concatenate multiple rows based on sequence in results set Pin
Shameel25-Jan-13 4:20
professionalShameel25-Jan-13 4:20 
GeneralRe: Query to concatenate multiple rows based on sequence in results set Pin
Alex Lush25-Jan-13 4:30
Alex Lush25-Jan-13 4:30 
AnswerRe: Query to concatenate multiple rows based on sequence in results set Pin
mmccarth25-Jan-13 6:21
mmccarth25-Jan-13 6:21 
QuestionSyntax error (Missing Operator) in Query expression ':0:1 Pin
IgaBaro23-Jan-13 15:40
IgaBaro23-Jan-13 15:40 
AnswerRe: Syntax error (Missing Operator) in Query expression ':0:1 Pin
Mycroft Holmes23-Jan-13 16:02
professionalMycroft Holmes23-Jan-13 16:02 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 Pin
IgaBaro23-Jan-13 16:25
IgaBaro23-Jan-13 16:25 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 Pin
PIEBALDconsult23-Jan-13 16:37
professionalPIEBALDconsult23-Jan-13 16:37 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 Pin
IgaBaro23-Jan-13 17:16
IgaBaro23-Jan-13 17:16 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 Pin
PIEBALDconsult23-Jan-13 17:26
professionalPIEBALDconsult23-Jan-13 17:26 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 Pin
IgaBaro23-Jan-13 17:58
IgaBaro23-Jan-13 17:58 
GeneralRe: Syntax error (Missing Operator) in Query expression ':0:1 Pin
PIEBALDconsult23-Jan-13 17:59
professionalPIEBALDconsult23-Jan-13 17:59 
AnswerRe: Syntax error (Missing Operator) in Query expression ':0:1 Pin
Richard MacCutchan24-Jan-13 0:22
mveRichard MacCutchan24-Jan-13 0:22 

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

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