How to import a .sql file with DTS

  • hi

    how can i import with dts a .sql file which contains sql statements like this:

    delete from tab_cdtrack where cd_nummer=102018 and trackszucd=1

    insert into tab_cdtrack (cd_nummer,trackszucd,tracknummer,tracktitel,dauer) values (102018,1,1,'kindgott',4.19)

    i tried to do a dts with a "Execute SQL Task", but the problem i have, is that everyday i have a .sql file to import. but the "Execute SQL Task" did not refresh the source file to import.

    could anyone help me and shows how to import such a file with dts.

    thanx

    urs

  • What do you want to do with the file? Can you clarify what your entire process is?

    Do you want to execute the sql statements? If so, you don't need to use DTS you can use the OSQL command line utility.

    Hope this helps

    Phill Carter

    --------------------

    Colt 45 - the original point and click interface

    --------------------
    Colt 45 - the original point and click interface

  • hi phil

    yes i like to execute the sql statements in this file.

    could you help me with an example script?

    thanks

    urs

  • isql /S servername /U username /P password -d databasename -b /m-1 /i filename 
    
    if ERRORLEVEL 1 pause

    I use this in .bat files to process my scripts to create database objects but you could use it for your purpose. The ERRORLEVEL test uses the result from isql to check if error occurred.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • hi david

    thanks for your script. where i have to put the .sql file?

    kind regards

  • Replace filename with the name of the .sql file, eg if the file you want to execute is called test.sql in the temp directory of your c: drive then would use

    isql /S servername /U username /P password -d databasename -b /m-1 /i c:\temp\test.sql 

    Remember to change the other parameters as well.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • when i execute "my" script, then i get an error:

    D:\>isql /S CeDe /U sa /P mwxloa -d CeDe_CD -b /m-1 /i D:\Tracks.sql

    1> 2> Msg 170, Level 15, State 1, Server CEDE, Line 1

    Line 1: Incorrect syntax near ' '.

    this is my script:

    isql /S CeDe /U sa /P mwxloa -d CeDe_CD -b /m-1 /i D:\Tracks.sql

    what's the problem? thanks

    urs

  • The script is executing but

    quote:


    1> 2> Msg 170, Level 15, State 1, Server CEDE, Line 1


    indicates that there is a sql syntax error in the file D:\Tracks.sql.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • hi david

    here is my sql statement.

    delete from tab_cdtrack where cd_nummer=102018

    when i test it in query analyzer its ok, but with isql no chance...

    maybe you can help me out there.

    urs

  • quote:


    Incorrect syntax near ' '.


    Just remembered, isql gives this error for unicode files. Try osql instead. Same parameters just replace isql with osql

    Far away is close at hand in the images of elsewhere.
    Anon.

Viewing 10 posts - 1 through 9 (of 9 total)

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