locked
how to add a row without a sql management studio RRS feed

  • Question

  • Hi,

    If I want to provide a way to INSERT rows to a table without having to use SMS, what is the way to go? Is there such a thing as a sql script? so that you can just change the data in the file and double click to write it to db?

    Thanks.

    Friday, August 27, 2010 11:09 PM

Answers

  • Double-click is possible but questionable if you want that sort of automation. If yo udon´t want or cannot have any client tools on the machine, you can use SQLCMD which is the successor of OSQL / ISQL. It is capable of defining every arguments for the connection as well as the execution. A call to a script file would be be something like the following:

    SQLCMD -iYourScript -SYourServer\InstanceNameIfApplicable -E

    (E = Trusted authentication, U & P would be username / password)

    You could register SQLCMD in Windows to be the default handler for .sql files thus double-clicking would be possible. Nevetheless, you would still have to make sure that the right server is targeted with the right authentication.

    A different server name can be targetted by using the :connect ServerName\InstanceIfApplicable in the .sql script itself.

    See the sqlcmd documentation for more information:

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

    And how to register a file handler:

    http://msdn.microsoft.com/en-us/library/cc144110(VS.85).aspx

    -Jens


    Jens K. Suessmeyer http://blogs.msdn.com/Jenss
    • Proposed as answer by Chirag Shah Sunday, August 29, 2010 11:24 AM
    • Marked as answer by TMLP Monday, August 30, 2010 6:05 PM
    Sunday, August 29, 2010 8:13 AM

All replies

  • In Books Online consult the Command Prompt Utilities. New release of SQL Server have more possibilities than older ones.
    Tom
    Saturday, August 28, 2010 1:54 AM
  • Double-click is possible but questionable if you want that sort of automation. If yo udon´t want or cannot have any client tools on the machine, you can use SQLCMD which is the successor of OSQL / ISQL. It is capable of defining every arguments for the connection as well as the execution. A call to a script file would be be something like the following:

    SQLCMD -iYourScript -SYourServer\InstanceNameIfApplicable -E

    (E = Trusted authentication, U & P would be username / password)

    You could register SQLCMD in Windows to be the default handler for .sql files thus double-clicking would be possible. Nevetheless, you would still have to make sure that the right server is targeted with the right authentication.

    A different server name can be targetted by using the :connect ServerName\InstanceIfApplicable in the .sql script itself.

    See the sqlcmd documentation for more information:

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

    And how to register a file handler:

    http://msdn.microsoft.com/en-us/library/cc144110(VS.85).aspx

    -Jens


    Jens K. Suessmeyer http://blogs.msdn.com/Jenss
    • Proposed as answer by Chirag Shah Sunday, August 29, 2010 11:24 AM
    • Marked as answer by TMLP Monday, August 30, 2010 6:05 PM
    Sunday, August 29, 2010 8:13 AM