script out a list of tables/procs

I have a list of tables and Stored Procs I want to move from One server to another. Is it possible to pass the list of tablenames and Stored procs and just pull out a script to run in the new server?

Thanks
LVL 6
anushahannaAsked:
Who is Participating?
 
Raja Jegan RConnect With a Mentor SQL Server DBA & ArchitectCommented:
Yes.. Use either

1. Apex SQL Diff (http://www.apexsql.com/sql_tools_diff.asp)
or
2. Red Gate Compare ( http://www.red-gate.com/products/SQL_Compare/index.htm)

and then provide the tables and procedures to be compared in both databases..
Since it is not present in your second server, both tools provide you with the option to synchronize the second server with your first server by creating a Synchronization script ( which is what you require)..

Just run the Synchronization script to get it created in the second server..
0
 
anushahannaAuthor Commented:
Just wanted to explain more clearly..

The tables and procs do not exist in the second server.

As an example, Database1 in Server1 may have 200 tables, and Database1 in Server2 has only 160 tables. I can generate the list of the remaining 40 tables and I would like to create a script with the 'create table ' scripts.. Likewise with the Stored Procs also..

thanks
0
 
fhillyer1Commented:
have you considered backing up on the first server and then restoring on the secong one?
i dont know if the data on the second server can be replaced, or you just want the structure with no data?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Raja Jegan RConnect With a Mentor SQL Server DBA & ArchitectCommented:
Of course you can implement it via Generate Scripts Wizard present in SSMS ( Except Express edition)..
But you can't do it via command line using Generate Scripts approach..

But the tools mentioned above, supports it..
0
 
PJBXCommented:
IF this is SQL Server, couldn't you simply use the SQL Server Import Export wizard?

http://www.aspfree.com/c/a/MS-SQL-Server/SQL-2000-Data-Transfer-is-a-Snap-with-SQL-2005/

OR

Backup Database1 and Restore the backup file to Database2?
0
 
anushahannaAuthor Commented:
backup & restore will not work. Server1's DB has data, but Server2's DB has another set of data, but should have same structure. Hence SSIS also will not work.

If I use Generate Scripts Wizard, it does not help to just choose those 40 tables, even if I can selected them, can I?

so, apart from 3rd party tools, what I need to get done is not possible with inbuilt tools, right?
0
 
Raja Jegan RConnect With a Mentor SQL Server DBA & ArchitectCommented:
>> If I use Generate Scripts Wizard, it does not help to just choose those 40 tables, even if I can selected them, can I?

You can select only the required objects but the limitation is that you achieve it using Wizard but can't do it in command line ( as you requested)..

If you prefer command line version, then you need to have third party tools.( Just generation of scripts and no comparison of scripts across databases)
If you don't want to spend on the extra cost, just proceed with the wizard.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.