sql scripts

  • Hi all

    need a bit of help please

    I know how to generate stanndard sql scripts but I need to have scripts that will include the data for the table this way I dont have to type and retype the information every time I have to drop the table

    I know I can simply export the data in the table to an excel spreadsheet and import back when I need it but I am sure that there is a way to what i just ask

    will appreciate any help

    thanks

  • No easy way. I'd use DTS and export the data and import it back. Or write a SQL statemeent that generates it for you

    select 'insert customers select ''' + customername + ''', ' + customerid

    from customers

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

  • RedGate has a product called Data Compare that generates inserts/updates necessary to sync two tables, saves as script. Doesnt support text columns though.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

  • If this is so you can restore the database or duplicate somewhere else then consider this. Create a database from the scripts and import the data you want to be able to duplicate. Then create a file backup or detach the database and store somewhere. The you copy and attach as you like or resotre from backup, depending on how you created.

    Or if this is not a whole lot then you can create an insert script like this.

    SELECT 'INSERT INTO tblName (COLUMNNAMESHERE) VALUES (''' + CharCol + ''', ' + CAST(IntCol AS VARCHAR(10)) + ')' AS insertstring FROM tblName

    However this also does not handle text, ntext and image columns but could possible be done with a bit of work. The first option handles everything.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

  • hey thanks for the answers

    will definitely be looking into the sugesstions

    I have already done the transferring data with the DTS was just wondering if there was a simpler/less clunky way

    thanks all the same

    cheers

    ============================================

    "A website is an application, just like one you have on your computer. People miss the point when they figure its a creative outlet. Creativity is what makes the application aesthetic. Useability is what makes it easy, and content is what makes it good. How sad most shoot for 1 out of 3 eh" - unknown author

  • I have a question out of curiosity, why you have to drop the table and recreate it later?

    Anyway, I think the best option is to use the data compare utility suggested.

    This will requiere from you to have a "repository" database for the tables you need to keep the information.

    The time you save with this utility is amazing! I use it everyday and it helps a lot.

    Not expensive, if I recall for a single user is around $95 if you get the bundle, which includes object compare it is around 195.

    I do not know prices these days, but it is not expensive at all for all the help you can get. Good luck!

  • hi

    I need to do that cause i am doing some freelance work and i work from home now i dont have an internet connection from home so i can connect to their prod. serever and work on that

    so I need to constantly script the Db as it changes on my home machine and then add then send a script to my employers so that they can have an up to date copy of the Db

    its a clunky way of doing things but once am alittle bit settled then i can dial into work and then I dont have to do this anymore

    also i dont know if its alright to ask ASP questions here, i am having problems with the way one of my sql statements is interacting with my asp

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply