Click here to Skip to main content
15,898,931 members
Home / Discussions / Database
   

Database

 
AnswerRe: integrity constraint Pin
Wendelius2-Feb-20 9:01
mentorWendelius2-Feb-20 9:01 
QuestionOracle SQL query to MS-SQL Pin
Member 951930620-Jan-20 22:37
Member 951930620-Jan-20 22:37 
AnswerRe: Oracle SQL query to MS-SQL Pin
Richard Deeming21-Jan-20 1:43
mveRichard Deeming21-Jan-20 1:43 
GeneralRe: Oracle SQL query to MS-SQL Pin
Member 951930628-Jan-20 22:44
Member 951930628-Jan-20 22:44 
GeneralRe: Oracle SQL query to MS-SQL Pin
Mycroft Holmes29-Jan-20 10:59
professionalMycroft Holmes29-Jan-20 10:59 
Questionsplit time then group by 15 min mongodb Pin
Member 1300557210-Jan-20 21:56
Member 1300557210-Jan-20 21:56 
QuestionSQL Query with a Loop Pin
Bobby Underwood6-Jan-20 4:58
Bobby Underwood6-Jan-20 4:58 
AnswerRe: SQL Query with a Loop Pin
#realJSOP6-Jan-20 5:04
professional#realJSOP6-Jan-20 5:04 
AnswerRe: SQL Query with a Loop Pin
Bobby Underwood6-Jan-20 5:11
Bobby Underwood6-Jan-20 5:11 
AnswerRe: SQL Query with a Loop Pin
#realJSOP6-Jan-20 5:16
professional#realJSOP6-Jan-20 5:16 
GeneralRe: SQL Query with a Loop Pin
Bobby Underwood6-Jan-20 5:22
Bobby Underwood6-Jan-20 5:22 
AnswerRe: SQL Query with a Loop Pin
Jörgen Andersson7-Jan-20 5:52
professionalJörgen Andersson7-Jan-20 5:52 
Questionincorrect syntax near begin expecting external for Alter Procedure Pin
simpledeveloper27-Dec-19 9:23
simpledeveloper27-Dec-19 9:23 
AnswerRe: incorrect syntax near begin expecting external for Alter Procedure Pin
Jörgen Andersson27-Dec-19 23:14
professionalJörgen Andersson27-Dec-19 23:14 
QuestionAdding multiple columns with condition Pin
simpledeveloper26-Dec-19 14:58
simpledeveloper26-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
simpledeveloper27-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
simpledeveloper27-Dec-19 8:44 
QuestionCrystal Report to SQL server 2012 database Pin
Member 1447460719-Dec-19 10:39
Member 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
Member 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
Member 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
David Mujica18-Dec-19 5:58 

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.