6

Anytime I use 'script table as' -> 'Insert To' (or other command), the script generated automatically places the database name in the script. Such as:

INSERT INTO [DatabaseName].[dbo].[tblToBeInserted] ...

While not a huge problem to just delete it, it has slipped by a few times and the script breaks if run on a different server with a different database name but has the same schema. (Such as running on [DatabaseName.Test])

Is there an option I can change, or can I modify the output in any way to remove this?

1
  • 1
    I though it might be a template in C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\sqlworkbenchprojectitems\Sql, but I'm not seeing it there. Commented Mar 19, 2010 at 21:42

3 Answers 3

3

in SSMS 18.x, Go to the "Tools" menu and then select "Options". from the left side of the Options window select "SQL Server Object Explorer" and then "Scripting". set "Script USE database" to False.

Sign up to request clarification or add additional context in comments.

Comments

2

Assuming that you are using Microsoft SQL Server Management Studio 2005 or higher you can goto the Tools -> Options menu. On the dialog select "Scripting" from the left hand side. On the right-side in the "General Scripting Options" section there is an option called "SCRIPT USE ". You can set that to FALSE.

1 Comment

I thought that too, but that only applies to the use database statement that is generated with creating/dropping tables. It does not remove it from Select/Insert/Update/Delete to options.
0

In SSMS, go to View -> Template Explorer, you can find a lot of templates there. Or, you can find these template .sql files from %appdata%\Microsoft\Microsoft SQL Server\100\Tools\Shell\Templates\Sql

2 Comments

Thanks, I did not know about templates. However, there is a new problem in that the specific templates I'm looking for do not exist in either template explorer, or in the folder location. Am I overlooking the templates? Also, in windows 7 the path is \AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell\Templates\Sql
%AppData% is a windows environment variable, which points to "C:\Users\xxx\AppData\Roaming". So if you type %AppData% in run box (win key + r), it will take you to "C:\Users\xxx\AppData\Roaming". "xxx" means the current windows logon account.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.