|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Management Studio - Open FileI was hoping this would be worked out with RTM, but it does not look like
it. I want to open a .sql file from disk in my current window. Whenever I try to open a file managment studio opens it into a new tab, prompts me for my connection info, and then opens it to my default database (usually Master). I want it to behave like Query Analyzer (good 'ole QA) and open the file into my current window without changing all my connection info. Am I missing something? Joe,
Put your cursor in the query editor and click "Insert File as Text" from the Edit menu. You can also add an "Insert File as Text" to the toolbar, so that this capability is just one click away! Michael Ray (MSFT) This posting is provided "AS IS" with no warranties, and confers no rights." When you include scripts, it should also include "Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm. Show quote "Joe" <j**@aol.com> wrote in message news:uwJBWw93FHA.3628@TK2MSFTNGP12.phx.gbl... >I was hoping this would be worked out with RTM, but it does not look like >it. > > I want to open a .sql file from disk in my current window. Whenever I try > to open a file managment studio opens it into a new tab, prompts me for my > connection info, and then opens it to my default database (usually > Master). > > I want it to behave like Query Analyzer (good 'ole QA) and open the file > into my current window without changing all my connection info. Am I > missing something? > > > > That's close but it is not the same as opening the file - it's more like
Insert Template. The query window I am working in has no idea what file it came from (ie. when I hit save I have to browse to the file I want to save and 'replace' it). Also, when I do the next 'Insert File as Text' it inserts the text wherever my cursor is instead of replacing the existing text with what is in the new file. Does Management Studio have a macro language or an Automation interface - kind of like you can automate Excel? I could probably work out this annoyance pretty easily with that... Show quote "Michael Ray (MSFT)" <mike***@online.microsoft.com> wrote in message news:%23AzrK$A4FHA.1148@tk2msftngp13.phx.gbl... > Joe, > > Put your cursor in the query editor and click "Insert File as Text" from > the Edit menu. > > You can also add an "Insert File as Text" to the toolbar, so that this > capability is just one click away! > > Michael Ray (MSFT) > > This posting is provided "AS IS" with no warranties, and confers no > rights." When you include scripts, it should also include "Use of included > script samples are subject to the terms specified at > http://www.microsoft.com/info/cpyright.htm. > > > "Joe" <j**@aol.com> wrote in message > news:uwJBWw93FHA.3628@TK2MSFTNGP12.phx.gbl... >>I was hoping this would be worked out with RTM, but it does not look like >>it. >> >> I want to open a .sql file from disk in my current window. Whenever I >> try to open a file managment studio opens it into a new tab, prompts me >> for my connection info, and then opens it to my default database (usually >> Master). >> >> I want it to behave like Query Analyzer (good 'ole QA) and open the file >> into my current window without changing all my connection info. Am I >> missing something? >> >> >> >> > > Exactly my objections. If you find out how to automate this, please let me
know. Show quote "Joe" <j**@aol.com> wrote in message news:uJjyb0K4FHA.3276@TK2MSFTNGP10.phx.gbl... > That's close but it is not the same as opening the file - it's more like > Insert Template. > > The query window I am working in has no idea what file it came from (ie. > when I hit save I have to browse to the file I want to save and 'replace' > it). Also, when I do the next 'Insert File as Text' it inserts the text > wherever my cursor is instead of replacing the existing text with what is in > the new file. > > Does Management Studio have a macro language or an Automation interface - > kind of like you can automate Excel? I could probably work out this > annoyance pretty easily with that... > > > > "Michael Ray (MSFT)" <mike***@online.microsoft.com> wrote in message > news:%23AzrK$A4FHA.1148@tk2msftngp13.phx.gbl... > > Joe, > > > > Put your cursor in the query editor and click "Insert File as Text" from > > the Edit menu. > > > > You can also add an "Insert File as Text" to the toolbar, so that this > > capability is just one click away! > > > > Michael Ray (MSFT) > > > > This posting is provided "AS IS" with no warranties, and confers no > > rights." When you include scripts, it should also include "Use of included > > script samples are subject to the terms specified at > > http://www.microsoft.com/info/cpyright.htm. > > > > > > "Joe" <j**@aol.com> wrote in message > > news:uwJBWw93FHA.3628@TK2MSFTNGP12.phx.gbl... > >>I was hoping this would be worked out with RTM, but it does not look like > >>it. > >> > >> I want to open a .sql file from disk in my current window. Whenever I > >> try to open a file managment studio opens it into a new tab, prompts me > >> for my connection info, and then opens it to my default database (usually > >> Master). > >> > >> I want it to behave like Query Analyzer (good 'ole QA) and open the file > >> into my current window without changing all my connection info. Am I > >> missing something? > >> > >> > >> > >> > > > > > > If you use Solutions and projects, then the project will associate each
script with the connection info you requested when you created the new script. So each time you open the script in the project, it knows what connection to use. I would always use "USE <DB>" on all scripts and not rely on default DB as you can burn yourself if you don't, plus it make good code style. If you want the same code on another connection, then create a new script and copy/paste the code in (update the USE statement if needed.) If you just open a .sql file without opening a project first, it has no idea what connection to use, so it prompts you for it. Does that help? -- Show quoteWilliam Stacey [MVP] "Joe" <j**@aol.com> wrote in message news:uwJBWw93FHA.3628@TK2MSFTNGP12.phx.gbl... >I was hoping this would be worked out with RTM, but it does not look like >it. > > I want to open a .sql file from disk in my current window. Whenever I try > to open a file managment studio opens it into a new tab, prompts me for my > connection info, and then opens it to my default database (usually > Master). > > I want it to behave like Query Analyzer (good 'ole QA) and open the file > into my current window without changing all my connection info. Am I > missing something? > > > > I think this is going to take a little getting used to.... Let me explain
what I do now and see if there are any suggestions. I have development, QA, staging, and production databases. When I am developing a new release I have Alter Table Sciprts, Stored Proc Changes, some DML for added records or data fixes. When writing in dev I number all the scripts with the filenames 01 - AlterTableCustomer.sql, 02 - AlterTableOrder.sql, 03 - TableCustomerSprocs.sql. This way when I go to QA I open script 1, run script 2, run, etc.... My dev and QA databases sit on the same server and have different names (so I can't use the USE). My staging and production databases are on a hosted server and also have different names. I agree that Management Studio does not know what server or database I am connecting to when I first open a script, but after I have selected it and I am opening a script from the context of a connection I have already established.... At the risk of sounding like I am harping on "the good 'ole days", Query Analyzer worked this way. I guess I could have separate projects for dev, qa, staging, and prod... I will have to experiment and try it out. Show quote "William Stacey [MVP]" <william.sta***@gmail.com> wrote in message news:%23vYQsdP5FHA.1248@TK2MSFTNGP14.phx.gbl... > If you use Solutions and projects, then the project will associate each > script with the connection info you requested when you created the new > script. So each time you open the script in the project, it knows what > connection to use. I would always use "USE <DB>" on all scripts and not > rely on default DB as you can burn yourself if you don't, plus it make > good code style. If you want the same code on another connection, then > create a new script and copy/paste the code in (update the USE statement > if needed.) > > If you just open a .sql file without opening a project first, it has no > idea what connection to use, so it prompts you for it. Does that help? > > -- > William Stacey [MVP] > > "Joe" <j**@aol.com> wrote in message > news:uwJBWw93FHA.3628@TK2MSFTNGP12.phx.gbl... >>I was hoping this would be worked out with RTM, but it does not look like >>it. >> >> I want to open a .sql file from disk in my current window. Whenever I >> try to open a file managment studio opens it into a new tab, prompts me >> for my connection info, and then opens it to my default database (usually >> Master). >> >> I want it to behave like Query Analyzer (good 'ole QA) and open the file >> into my current window without changing all my connection info. Am I >> missing something? >> >> >> >> > > hmm. Based on that you could do seperate projects as you said. However, I
am thinking what I would do is spend a day and work up a master update sproc with parms that does all this for you. Takes a source and updates a target db per your needs. -- Show quoteWilliam Stacey [MVP] "Joe" <j**@aol.com> wrote in message news:eNPCOpU5FHA.252@TK2MSFTNGP15.phx.gbl... >I think this is going to take a little getting used to.... Let me explain >what I do now and see if there are any suggestions. > > I have development, QA, staging, and production databases. When I am > developing a new release I have Alter Table Sciprts, Stored Proc Changes, > some DML for added records or data fixes. When writing in dev I number > all the scripts with the filenames 01 - AlterTableCustomer.sql, 02 - > AlterTableOrder.sql, 03 - TableCustomerSprocs.sql. This way when I go to > QA I open script 1, run script 2, run, etc.... > > My dev and QA databases sit on the same server and have different names > (so I can't use the USE). My staging and production databases are on a > hosted server and also have different names. > > I agree that Management Studio does not know what server or database I am > connecting to when I first open a script, but after I have selected it and > I am opening a script from the context of a connection I have already > established.... At the risk of sounding like I am harping on "the good > 'ole days", Query Analyzer worked this way. > > I guess I could have separate projects for dev, qa, staging, and prod... I > will have to experiment and try it out. > > > > "William Stacey [MVP]" <william.sta***@gmail.com> wrote in message > news:%23vYQsdP5FHA.1248@TK2MSFTNGP14.phx.gbl... >> If you use Solutions and projects, then the project will associate each >> script with the connection info you requested when you created the new >> script. So each time you open the script in the project, it knows what >> connection to use. I would always use "USE <DB>" on all scripts and not >> rely on default DB as you can burn yourself if you don't, plus it make >> good code style. If you want the same code on another connection, then >> create a new script and copy/paste the code in (update the USE statement >> if needed.) >> >> If you just open a .sql file without opening a project first, it has no >> idea what connection to use, so it prompts you for it. Does that help? >> >> -- >> William Stacey [MVP] >> >> "Joe" <j**@aol.com> wrote in message >> news:uwJBWw93FHA.3628@TK2MSFTNGP12.phx.gbl... >>>I was hoping this would be worked out with RTM, but it does not look like >>>it. >>> >>> I want to open a .sql file from disk in my current window. Whenever I >>> try to open a file managment studio opens it into a new tab, prompts me >>> for my connection info, and then opens it to my default database >>> (usually Master). >>> >>> I want it to behave like Query Analyzer (good 'ole QA) and open the file >>> into my current window without changing all my connection info. Am I >>> missing something? >>> >>> >>> >>> >> >> > > Cannot use "USE". On our development server, we have 30 databases, all with
the same structure, but different data. I need to stay in the same database when I open a new file, so I don't have to browse again among the 30 databases. Show quote "William Stacey [MVP]" <william.sta***@gmail.com> wrote in message news:%23vYQsdP5FHA.1248@TK2MSFTNGP14.phx.gbl... > If you use Solutions and projects, then the project will associate each > script with the connection info you requested when you created the new > script. So each time you open the script in the project, it knows what > connection to use. I would always use "USE <DB>" on all scripts and not > rely on default DB as you can burn yourself if you don't, plus it make good > code style. If you want the same code on another connection, then create a > new script and copy/paste the code in (update the USE statement if needed.) > > If you just open a .sql file without opening a project first, it has no idea > what connection to use, so it prompts you for it. Does that help? > > -- > William Stacey [MVP] > > "Joe" <j**@aol.com> wrote in message > news:uwJBWw93FHA.3628@TK2MSFTNGP12.phx.gbl... > >I was hoping this would be worked out with RTM, but it does not look like > >it. > > > > I want to open a .sql file from disk in my current window. Whenever I try > > to open a file managment studio opens it into a new tab, prompts me for my > > connection info, and then opens it to my default database (usually > > Master). > > > > I want it to behave like Query Analyzer (good 'ole QA) and open the file > > into my current window without changing all my connection info. Am I > > missing something? > > > > > > > > > > This issue is really bugging me too. Sometimes I just have to browse through
a bunch of files. I do not want to open a new window and click the "Connect" button every time. I want to stay in the same window, with the same connection. I can't believe I can't do that anymore. Show quote "Joe" <j**@aol.com> wrote in message news:uwJBWw93FHA.3628@TK2MSFTNGP12.phx.gbl... > I was hoping this would be worked out with RTM, but it does not look like > it. > > I want to open a .sql file from disk in my current window. Whenever I try > to open a file managment studio opens it into a new tab, prompts me for my > connection info, and then opens it to my default database (usually Master). > > I want it to behave like Query Analyzer (good 'ole QA) and open the file > into my current window without changing all my connection info. Am I > missing something? > > > > Wow, not only do I have to do click the Connect button each time, I have to
browse through the 30 databases on that server and pick again the database I want to be in. OK, going back to Query Analyzer 2000. Show quote "Vlad" <dracul***@mediaone.net> wrote in message news:uQU83iv5FHA.884@TK2MSFTNGP14.phx.gbl... > This issue is really bugging me too. Sometimes I just have to browse through > a bunch of files. I do not want to open a new window and click the "Connect" > button every time. I want to stay in the same window, with the same > connection. I can't believe I can't do that anymore. > > > "Joe" <j**@aol.com> wrote in message > news:uwJBWw93FHA.3628@TK2MSFTNGP12.phx.gbl... > > I was hoping this would be worked out with RTM, but it does not look like > > it. > > > > I want to open a .sql file from disk in my current window. Whenever I try > > to open a file managment studio opens it into a new tab, prompts me for my > > connection info, and then opens it to my default database (usually > Master). > > > > I want it to behave like Query Analyzer (good 'ole QA) and open the file > > into my current window without changing all my connection info. Am I > > missing something? > > > > > > > > > > I agree with the people above.
I like the 'old' Query Analyzer behaviour too :-( Drag in the files and they are all opened with the same connection and databasename. We too have lots of seperate databases and environments. I still use QA because of this missing feature in Management Studio. This "problem", and other problems annoyed me to the point that I have
uninstalled SQL 2005 and stopped evaluation of the product until MS decides to put some admin/developer friendly features back into the product. Sure they say, just use projects, well, maybe everyone doesn't work in that strict of an environment? It just seems that for an upgrade, there are many basic functions that are now more difficult to perform, hardly what an upgrade should be! Why can't we select multiple tables and set permissions for example? SQL 7 had that feature, if I remember correctly. Dan Show quote "Vlad" <dracul***@mediaone.net> wrote in message news:uQU83iv5FHA.884@TK2MSFTNGP14.phx.gbl... > This issue is really bugging me too. Sometimes I just have to browse > through > a bunch of files. I do not want to open a new window and click the > "Connect" > button every time. I want to stay in the same window, with the same > connection. I can't believe I can't do that anymore. > > > "Joe" <j**@aol.com> wrote in message > news:uwJBWw93FHA.3628@TK2MSFTNGP12.phx.gbl... >> I was hoping this would be worked out with RTM, but it does not look like >> it. >> >> I want to open a .sql file from disk in my current window. Whenever I >> try >> to open a file managment studio opens it into a new tab, prompts me for >> my >> connection info, and then opens it to my default database (usually > Master). >> >> I want it to behave like Query Analyzer (good 'ole QA) and open the file >> into my current window without changing all my connection info. Am I >> missing something? >> >> >> >> > > Workaround Description:
Start Management Studio with -S and -d switches Workaround Steps: #1 Copy the menu item "SQL Server Management Studio" onto your desktop. #2 In the Properties dialog, 'Shortcut' tab, 'Target' field, add -E -S <server> -d <database> -nosplash after "C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\SqlWb.exe" (and put a space between the two). #3 Start Management Studio using the icon, or drag .sql files, from Windows Explorer, onto the icon. Obviously, the limitations are #1 having to hard code the Server and database names #2 starting a new copy of Management Studio each time you drop files. BUT, once Management Studio is opened this way, the File / Open menu operation, as well as dragging and dropping more files into the query window, uses the startup Server and database to logon -- bypassing the connection prompt. |
|||||||||||||||||||||||