script out a list of tables/procs

Posted on 2009-12-28
Last Modified: 2012-05-08
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?

Question by:anushahanna
    LVL 6

    Author Comment

    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..

    LVL 5

    Expert Comment

    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?
    LVL 57

    Accepted Solution

    Yes.. Use either

    1. Apex SQL Diff (
    2. Red Gate Compare (

    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..
    LVL 57

    Assisted Solution

    by:Raja Jegan R
    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..
    LVL 6

    Expert Comment

    IF this is SQL Server, couldn't you simply use the SQL Server Import Export wizard?


    Backup Database1 and Restore the backup file to Database2?
    LVL 6

    Author Comment

    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?
    LVL 57

    Assisted Solution

    by:Raja Jegan R
    >> 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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
    Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now