Click here to Skip to main content
14,635,060 members
Home » Discussions » Database
   

Database

 
QuestionAdding multiple columns with condition Pin
simpledeveloper26-Dec-19 14:58
Membersimpledeveloper26-Dec-19 14:58 
AnswerRe: Adding multiple columns with condition Pin
Mycroft Holmes26-Dec-19 19:58
professionalMycroft Holmes26-Dec-19 19:58 
AnswerRe: Adding multiple columns with condition Pin
Jörgen Andersson27-Dec-19 3:40
professionalJörgen Andersson27-Dec-19 3:40 
GeneralRe: Adding multiple columns with condition Pin
simpledeveloper27-Dec-19 5:29
Membersimpledeveloper27-Dec-19 5:29 
GeneralRe: Adding multiple columns with condition Pin
Jörgen Andersson27-Dec-19 5:32
professionalJörgen Andersson27-Dec-19 5:32 
GeneralRe: Adding multiple columns with condition Pin
simpledeveloper27-Dec-19 8:44
Membersimpledeveloper27-Dec-19 8:44 
QuestionCrystal Report to SQL server 2012 database Pin
Member 1447460719-Dec-19 10:39
MemberMember 1447460719-Dec-19 10:39 
QuestionBackup rows tables of SQL Server database by SMO base on colums's value Pin
Member 1417466417-Dec-19 14:39
MemberMember 1417466417-Dec-19 14:39 
I am following this article to backup database, but in that, will be backup all rows of all tables in database. But I want backup only rows of all tables that value of department column is '10' (in my database, all tables also having department column).

Can someone help me the how to changes CreateScriptTable() backup. My code app is winform C#

public void CreateScriptDataBase(string dataBaseName, string connectionString)
{
    SqlConnection con = new SqlConnection(connectionString);
    ServerConnection serverConnection = new ServerConnection(con);
    Server server = new Server(serverConnection);
    Database database = server.Databases["" + dataBaseName + ""];
    if (database != null)
    {
        Scripter scripter = new Scripter(server);
        scripter.Options.ScriptData = true;
        scripter.Options.ScriptSchema = true;
        scripter.Options.ScriptDrops = false;
        var sb = new System.Text.StringBuilder();
        foreach (Microsoft.SqlServer.Management.Smo.Table table in database.Tables)
        {
            sb.Append("DROP TABLE " + table.Name);
            sb.Append(Environment.NewLine);
            foreach (string s in scripter.EnumScript(new Urn[] { table.Urn }))
            {
                sb.Append(s);
                sb.Append(Environment.NewLine);
            }
            string folder = Server.MapPath("~/Scripts/");
            string filename = folder + dataBaseName + ".sql";
            System.IO.StreamWriter fs = System.IO.File.CreateText(filename);
            fs.Write(sb);
            fs.Close();
        }
    }
}

AnswerRe: Backup rows tables of SQL Server database by SMO base on colums's value Pin
Richard Deeming17-Dec-19 23:47
mveRichard Deeming17-Dec-19 23:47 
GeneralRe: Backup rows tables of SQL Server database by SMO base on colums's value Pin
Member 1417466417-Dec-19 23:57
MemberMember 1417466417-Dec-19 23:57 
AnswerRe: Backup rows tables of SQL Server database by SMO base on colums's value Pin
David Mujica18-Dec-19 5:58
MemberDavid Mujica18-Dec-19 5:58 
GeneralRe: Backup rows tables of SQL Server database by SMO base on colums's value Pin
Member 1417466418-Dec-19 14:35
MemberMember 1417466418-Dec-19 14:35 
GeneralRe: Backup rows tables of SQL Server database by SMO base on colums's value Pin
David Mujica19-Dec-19 9:37
MemberDavid Mujica19-Dec-19 9:37 
GeneralCode converter Pin
David Mujica19-Dec-19 9:47
MemberDavid Mujica19-Dec-19 9:47 
GeneralRe: Code converter Pin
Member 1417466419-Dec-19 16:01
MemberMember 1417466419-Dec-19 16:01 
AnswerRe: Backup rows tables of SQL Server database by SMO base on colums's value Pin
Member 1417466430-Jan-20 22:40
MemberMember 1417466430-Jan-20 22:40 
Questionms sql server error 18456 on sa login Pin
pwojtysiak17-Dec-19 0:24
Memberpwojtysiak17-Dec-19 0:24 
AnswerRe: ms sql server error 18456 on sa login Pin
Richard Deeming17-Dec-19 1:33
mveRichard Deeming17-Dec-19 1:33 
QuestionSQL Server Management Studio VS SQL Server in Visual Studio 2019 Pin
Ebrahimaw21-Nov-19 19:33
MemberEbrahimaw21-Nov-19 19:33 
AnswerRe: SQL Server Management Studio VS SQL Server in Visual Studio 2019 Pin
Richard MacCutchan21-Nov-19 21:36
mveRichard MacCutchan21-Nov-19 21:36 
QuestionRe: SQL Server Management Studio VS SQL Server in Visual Studio 2019 Pin
ZurdoDev22-Nov-19 9:36
mveZurdoDev22-Nov-19 9:36 
AnswerRe: SQL Server Management Studio VS SQL Server in Visual Studio 2019 Pin
Mycroft Holmes22-Nov-19 11:36
professionalMycroft Holmes22-Nov-19 11:36 
AnswerRe: SQL Server Management Studio VS SQL Server in Visual Studio 2019 Pin
Eddy Vluggen22-Nov-19 15:10
professionalEddy Vluggen22-Nov-19 15:10 
GeneralRe: SQL Server Management Studio VS SQL Server in Visual Studio 2019 Pin
Ebrahimaw25-Nov-19 16:48
MemberEbrahimaw25-Nov-19 16:48 
GeneralRe: SQL Server Management Studio VS SQL Server in Visual Studio 2019 Pin
Eddy Vluggen26-Nov-19 1:32
professionalEddy Vluggen26-Nov-19 1:32 

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.