February 24, 2025 at 8:32 pm
While I know that it will speed my learning to type queries as I need them, sometimes I have put other people's queries to good use, queries that I lack the skills to create but will likely use in the future. Alas, I find no way to store and retrieve queries making them very accessable. No doubt, there is a way to do this using SSMS. I just haven't found it and I've done a lot of searching for the answer.
As a workaround, I've created a folder in Windows File Explorer for keeping them available. First I put the query in a notepad .txt file the save them into that folder with a (hopefully) good mnemonic filename. This is a first order KLUDGE!
Please, if there is a way to do this in SSMS, tell me.
As for second part, Git/Github use for db version control, I've read articles that went over my head. If anyone can a) tell me if this is a good or bad idea - worth or not worth pursuing, please tell me; b) if it's worth pursuing, please point me to a simple wiki or tell me how it's done. In the same vein, should SQL Server queries be made available to VS Code? I've run across the need at least once to see my website code and my database queries in VS Code. Please, I need advice.
Be kind. Be calm. Be generous. Behave.
February 24, 2025 at 10:35 pm
You can use the menu option File | Save
or File | Save As
to save the .sql file to any location you want. By default - there will be a folder created under the Documents folder for SQL Server scripts.
Something else you can do is create a solution and manage the files through a solution. To see that - select View | Solution Explorer
.
As for your other questions related to Azure - that is really the DevOps portion, which is similar to Git in how it is utilized for source code. Either can be used for your SQL files - but if you really want to manage your SQL files in either of those, then you would need to switch to Visual Studio with the SSDT tools installed.
With those tools - you can then connect to your repo directly from VS, check out, check in, etc.
However, for where you are at in your development now - I would not be too concerned with getting changes into source control. What you really need right now is to save your files as you are developing. Once you get to the point where you have a minimally viable product - that is when I would make sure everything was in source control.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
February 24, 2025 at 11:13 pm
Thanks, Jeffrey.
I have made it a practice to right click tabs in SSMS windows and choose Save filename. I haven't paid much attention to the pathname. You've given another lesson. I might find a way to save SQL files associated with my website development in the same root folder as the HTML/CSS/JS and other files. Will that make them accessible to VS Code? Another rabbit to chase but I won't dive into that hole just yet.
Be kind. Be calm. Be generous. Behave.
February 25, 2025 at 12:53 am
I investigated and found that my queries were saved in the Documents folder accessible from File Explorer. Is that because they are basically text files? I suppose that to be the case because other files saved by SSMS are not stored there.
I then decided that I wanted to have those queries saved from SSMS to be in a folder of my choice instead of forcing them Documents. I tried Tools > Options > Environment > Import and Export Files only to learn that option applies at the file only level, which I found strange. It is the equivalent of a Save As option but requires a lot of mouse clicks to reach when a Save As option on right clicking an objects tab would be far easier.
Guessing that no one here can speak for Microsoft about the issue, I wondered if my lack of knowledge and experience is the problem. Is there a way to set a default path for objects of all types to be saved to? If so, where are the controls to make that happen?
TIA
Be kind. Be calm. Be generous. Behave.
March 5, 2025 at 3:16 pm
Under "Tools | Options | Projects and Solutions | Locations" you can set your project location which if memory serves me would also be the default location for saving .sql files.
Also, since you asked about source control, the new version of SSMS that is currently in preview will have git integration built in. I have not tried the preview but this may be something you want without having to switch to Visual Studio.
One more item - if you want a text editor that supports syntax highlighting of SQL files as well as many others, notepad++ is very useful. It's open source and a free download.
March 5, 2025 at 4:02 pm
If you save .sql files in a folder under your HTML/etc files, and this is a repo, you can open the entire folder in VS Code and edit any file. There is an MSSQL extension for VSCode that helps here: https://learn.microsoft.com/en-us/sql/tools/visual-studio-code-extensions/mssql/mssql-extension-visual-studio-code?view=sql-server-ver16
March 5, 2025 at 7:52 pm
Thank you, Gentlemen.
That helps a lot.
Be kind. Be calm. Be generous. Behave.
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy