Creating Script from Stored Procedure

  • Hi,

    I have a Db in MSSQL2005. Some of the machines running the front end are stand alone and so have their own sql db. I want to copy changes in these stand alone db tables after a specific date, store them in a portable file and and import them to the central db. One of the tables contain images too. I attempted running through individual tables, select required records, create strings and write them all to a text file, run the file in the machine where the central db is...... all using the front end....... I face problems in handling images. And I know it is better to use stored procedures...... But I am a fresher and not able to figure out a solution..........

    Help!!!!!!!!!.........................

    Sanya

  • sanya.ibrahim (10/19/2008)


    Hi,

    I have a Db in MSSQL2005. Some of the machines running the front end are stand alone and so have their own sql db. I want to copy changes in these stand alone db tables after a specific date, store them in a portable file and and import them to the central db. One of the tables contain images too. I attempted running through individual tables, select required records, create strings and write them all to a text file, run the file in the machine where the central db is...... all using the front end....... I face problems in handling images. And I know it is better to use stored procedures...... But I am a fresher and not able to figure out a solution..........

    Help!!!!!!!!!.........................

    Sanya

    Sanya,

    What problems are you facing in migrating images across the machines and what makes you think that stored procedures would be a solution to your problem?

    If you could please tell how and what you have tried, what errors you got, then it would be easy to provide help.

    Also, how are these images stored in the database - as blobs or containing a file path reference to image file on disk?

  • Hi SSC-Enthusiastic,

    Thanks for the reply. Let me elaborate on present procedure adopted by me. I am selecting the required fields row by row from all relevant tables containing varchar or date fields and create strings in sql insert/update statement format. These strings are written to a txt file.

    The images are saved as long varbinary and I am saving them as .jpg files in the HDD. The update / select statemets for these images are also included in the abovementioned txt file with reference to the location where the images are saved.

    I am presently doing all these with the front (vb.net2005). I presume that this is not the best way as I have difficulty in executing the txt file and incorporating the images in the update / insert statement. So I am looking for a stored procedure that will generate an sql script file that contains the required data.

    Please correct me if I am wrong in the propsed plan. Any better suggestions will be deeply appreciated.

  • To make SQL changes from the different machines to the central server. Create an Insert trigger on the frontend data sources tables that will insert the currently updated row into the central server. This will prevent the use of the txt files.

    kshitij kumar
    kshitij@krayknot.com
    www.krayknot.com

  • Hi Grasshopper,

    the txt files are required to transfer data from "stand alone" machines to central database......No network connection is available......

  • sanya.ibrahim (10/19/2008)


    Hi,

    I have a Db in MSSQL2005. Some of the machines running the front end are stand alone and so have their own sql db. I want to copy changes in these stand alone db tables after a specific date, store them in a portable file and and import them to the central db. One of the tables contain images too. I attempted running through individual tables, select required records, create strings and write them all to a text file, run the file in the machine where the central db is...... all using the front end....... I face problems in handling images. And I know it is better to use stored procedures...... But I am a fresher and not able to figure out a solution..........

    Help!!!!!!!!!.........................

    Sanya

    In that case, you should use Differential backup and restore. for more informatioin:

    http://msdn.microsoft.com/en-us/library/ms186865.aspx

    kshitij kumar
    kshitij@krayknot.com
    www.krayknot.com

  • User DTS, to transfer the .txt file data into SQL Server.

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

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