Hi,
I want to generate a database script for all tables only same as we do it in SQL Management Studio manually using SMO in C#.
Thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kirtan PatelPosted Dec 8, 2009, 10:06 PM
Here is your Solution .
Just Run Following Commands Programatically . and it will Create the Script Files .
private void button1_Click(object sender, EventArgs e)
{
Process p = new Process();
p.StartInfo.FileName = @"C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz";
p.StartInfo.Arguments= @"script -d AdventureWorks "C:\AdventureWorks.sql";
p.Start();
}
Other commands wich will helps you ,are below just Execute it like above :)
Command to run which will create schema and database:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks "C:\AdventureWorks.sql"
Command to run which will create schema:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks "C:\AdventureWorks.sql" -schemaonly
Command to run which will create data:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks "C:\AdventureWorks.sql" -dataonly
jayakrishnan MorayurPosted Mar 11, 2011, 12:31 AM
"An error has occured while cnnection to database"
please replay
Amit GautamPosted Jul 27, 2010, 9:07 AM
code is-
protected void Button1_Click(object sender, EventArgs e)
{
Process p = new Process();
p.StartInfo.FileName = @"C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz";
p.StartInfo.Arguments= @"script -d AdventureWorksC:\AdventureWorks.sql";
p.Start();
}
VikramPosted Dec 9, 2009, 6:42 AM
Thanks for your reply. Its working fine. But it gives schema of all objects, actually I want schema of tables only. Is is possible with same option.
Thanks,