question

venkatreddy avatar image
venkatreddy asked

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.

t-sqlsubjectivecommand-line
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Fatherjack avatar image
Fatherjack answered

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

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Matt Whitfield avatar image
Matt Whitfield answered

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.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bhaskar avatar image
Bhaskar answered

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/

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.