SSMS: open .sql file always towards a server ?

  • Is there a way to open a .sql file in SSMS always towards a particular sql server instance.

    because, when i open a new .sql file, by default it assumes a connection which i was working with a previous .sql file.

    this some times prone to mistakes in fetching wrong data (like SELECTed from DEV instead PROD).

    Appreciating your help always.

  • Not quite what you're after, but right click over the toolbar in SSMS and select Customize. On the Commands tab select File. There is an option Open File with New Connection which you can drag on to the toolbar.

  • SQL Mad Rafi (6/12/2012)


    Is there a way to open a .sql file in SSMS always towards a particular sql server instance.

    because, when i open a new .sql file, by default it assumes a connection which i was working with a previous .sql file.

    this some times prone to mistakes in fetching wrong data (like SELECTed from DEV instead PROD).

    Appreciating your help always.

    If you go to File/New/Project and add a SQL Server Scripts project, scripts held in this will be associated with a connection. Is this more or less what you're looking for?

  • David Atkinson (6/13/2012)


    SQL Mad Rafi (6/12/2012)


    Is there a way to open a .sql file in SSMS always towards a particular sql server instance.

    because, when i open a new .sql file, by default it assumes a connection which i was working with a previous .sql file.

    this some times prone to mistakes in fetching wrong data (like SELECTed from DEV instead PROD).

    Appreciating your help always.

    If you go to File/New/Project and add a SQL Server Scripts project, scripts held in this will be associated with a connection. Is this more or less what you're looking for?

    Yes. Great.

    Thanks a lot David.

    This is what i looked for, that the .sql file that i added under 'Queries' folder remembers the connection which i set with it once. when i am opening the project again, each script file opens with its own connection which i set.

Viewing 5 posts - 1 through 4 (of 4 total)

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