x
login about faq Site discussion (meta-askssc)

Generating script for a table using command line

How to generate script(also want to save) for a table using command line.I want to connect to sql server through command line.Can i create a procedure and invoke from command line? help me.thanks in advance.

more ▼

asked Apr 28 '10 at 05:18 AM in Default

venkatreddy gravatar image

venkatreddy
562 26 28 32

(comments are locked)
10|1200 characters needed characters left

3 answers: sort voted first

you can execute SQL statements from the command line using the osql utility. http://msdn.microsoft.com/en-us/library/aa213090%28SQL.80%29.aspx

more ▼

answered Apr 28 '10 at 05:30 AM

Fatherjack gravatar image

Fatherjack ♦♦
38.8k 56 73 104

(comments are locked)
10|1200 characters needed characters left

The two ways that come to mind both involve using SMO. One way would be to use Powershell to fire it off, and the other would be two write a C# application to do it.

But, effectively, there would be very little difference between the two approaches.

more ▼

answered Apr 28 '10 at 05:31 AM

Matt Whitfield gravatar image

Matt Whitfield ♦♦
29.2k 56 63 87

(comments are locked)
10|1200 characters needed characters left

There is publishing wizard which can be executed from command line. There is good article on this, I just tried it.

http://blog.sqlauthority.com/2007/11/16/sql-server-2005-generate-script-with-data-from-database-database-publishing-wizard/

more ▼

answered Apr 28 '10 at 10:56 AM

Bhaskar gravatar image

Bhaskar
333 15 17 20

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x916
x21
x7

asked: Apr 28 '10 at 05:18 AM

Seen: 2454 times

Last Updated: Apr 28 '10 at 05:18 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.