x

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 28 29 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 ♦♦
41.2k 72 77 107

(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.4k 61 65 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 16 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.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

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

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x977
x21
x7

asked: Apr 28 '10 at 05:18 AM

Seen: 3258 times

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