In SQL server is there any way to get the 'use database' command to accept a variable

前端 未结 4 763
醉酒成梦
醉酒成梦 2020-12-17 22:37

I would like to write a \'generic\' script to operate on a number of databases. The \'use databasename\' commands will be distributed in the body of the script. I would rath

4条回答
  •  旧时难觅i
    2020-12-17 23:02

    You could NOT put a use statement in your script, and supply the database with the osql command (or whatever you're using) like this:

    osql -S servername -d databasename -U username -P password -i script.sql
    

提交回复
热议问题