How to remove database name from generated SQL Server script?

Anytime I use 'script table as' → 'Insert To' (or another command), the created script automatically puts the database name in the script. For instance:

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

Although this is not a huge problem, just to remove it, it has shifted several times, and the script breaks if it is executed on another server with a different database name, but it has the same scheme. (For example, running on [DatabaseName.Test])

Is there an option that I can change, or can I somehow change the output?

+4
source share
2 answers

Assuming you are using Microsoft SQL Server Management Studio 2005 or higher, you can go to Tools → Options. In the dialog box, select Scripts on the left. To the right in the section "General script parameters" is the option "SCRIPT USE". You can set the value to FALSE.

+1
source

In SSMS, go to View → Template Explorer, where you can find many templates. Or you can find these .sql file templates from% appdata% \ Microsoft \ Microsoft SQL Server \ 100 \ Tools \ Shell \ Templates \ Sql

0
source

Source: https://habr.com/ru/post/1304588/


All Articles