I've just installed SSMS v18.6 and surprisingly I noticed that there's no debug menu anymore! I'm very dependent on debugging my SQL scripts like stored procs. Can anyone explain how I can achieve this? Any help would be much appreciated.
Debugging capabilities are no longer available in SSMS v18.0 onwards. I guess it's not been in high demand and also because of the overload it has imposed on the software. If you still need to debug your SQL scripts you can do it by using Visual Studio. There is a good video at How to debug SQL code showing you how to achieve your goal.
You can debug the SQL Server stored procedure and scripts with Visual Studio.NET,
Open the Visual Studio.NET and click the continue without code (link)
Connect to SQLServer in Visual Studio.NET. Menu Tools->SQL Server->New Query
Enter Sql Server Connection Data
In script note write your script or Invoke the Stored procedure or User define function
F9 or double click left of code line for out the break point
In menu SQL-> Execute with debugger
with F11 trace line By line
Complete
Related
So I am unfortunate enough to work in an organization who uses SSMS18, meaning I don't have the built-in debugger for SSMS. I am relegated to using VS2019 Professional to set break points and step through stored procedures. No Biggie, right?
Well when I select "Execute with Debugger" (can't see the selection in GIF for some reason) it loads then executes and never hits my breakpoint.
I followed these posts below to no avail.
How to debug stored procedure in VS 2015?
This one I could not find what he was describing in step 6, but I debugged a SQL-Query in VS2019 before, but that was a local instance and not a remote server like it is in this case.
Cannot execute breakpoint inside stored procedure from VS 2017
below is a gif of what is happening
Any and all help is greatly appreciated.
Download and Install a version of SSMS < version 18. Then you will be able to debug.
I have my database on another system and I want to debug remotely using visual studio 2019. Setting up a connection works to the database but debugging a stored procedure does not work. I get a message box indicating 'Unable to start the Transact-SQL debugger, could not connect to the Database Engine instance 'servername\instancename'. Make sure you have enabled the debugging firewall exceptions and are using a login that is a member of the sysadmin fixed server role. Click Help for more information.
The user that I am using has sysadmin role, checked it using the 'SELECT IS_SRVROLEMEMBER('sysadmin', 'YourLogin') command. I have disable the firewall on the remote machine. Locally I have enabled port 1433, 1434 and 135. Unfortunately this does not resolves the issue.
I had the same problem and then remembered reading about Debugging firewall ports when I installed SQLServer 2019.
With SS 2014 I didn't get any error messages but when I tried to debug with SS2019 it said possible firewall block.
https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/s0fk6z6e(v=vs.100)
Why aren't my breakpoints hitting SQL In Visual Studio 2019 debugging
script from network server
According to your issue, you can try to follow my steps:
One
1) connect the database in SQL Server Explorer and make sure you can access the data successfully.
2) right-click on the selected procedure and choose Execute Procedure Option. Then it will open a new query window where you can execute your stored procedure as shown below.
An easy way is that you can just choose Debug Procedure, it will debug your procedure directly and you should not follow the below steps.
3) set a new breakpoint in the query file and select Execute with Debugger.Since you cannot open the green arrow's drop-down box, you can select the menu on the top bySQL-->Execute with Debugger to debug your procedure.
Besides, please remember to select the right database before debugging so that you don't run debug statements against other databases.
Note: If your stored procedure requires parameters as input, Visual Studio will prompt you to enter the values before opening the new query window.
More info you can refer to this.
Two
1) Right-click on the Project in the Solution Explorer-->Add--> Script-->Script(Not in Build).
2) Write a custom query to select your procedure like exec dbo.Users_GetUserInfo and then choose SQL-->Execute with Debugger.
Hope it could help you.
SQL Server Management Studio used to have Debug functionality that would allow to step through the code and watch the values etc. Referring to How to add the Debug button to SSMS v18?, I understand that the functionality is removed from SQL Server Management Studio V18.1.
But what is the alternative now? How do you step through the code to pinpoint a bug in the code?
You can use Visual Studio (the full IDE) to do it:
Use "Server Explorer" (Under the View menu) to connect to your DB
Right-click the DB and choose "New Query" (or find a stored procedure to debug)
Set a break point (F9 key or otherwise) on a line of SQL
Right-click inside the SQL editor and choose "Execute with Debugger"
Your best option is to not upgrade version 18.X, but stay on 17.9 until the Microsoft Product Manager gets sacked. A similar thing happened in going from SQL Server 2000 to SQL Server 2k5. Eventually, they capitulated and re-introduced the feature.
Ta for answer above, but when trying to debug with Sever Explorer, I find that "SQL Debugging is not supported on Microsoft Azure SQL Database'... ho hum, so I downgrade to SSMS 17.9 or dump the database to local and do it there.
Nice, I just wanted to quickly debug something... by the time I've done that lot I'll have forgotten what the problem I was trying to fix was !
It's deprecated, so you don't. Personally, I never use the feature and I'm assuming many others didn't either (which is why it's being retired).
The work around is to debug stored procedures by outputting values using PRINT or RAISERROR. Using BEGIN TRAN / ROLLBACK this works well because you can easily run code against the same data.
It's not the same as step through debugging, but it works.
I know this was asked many times, I've read them.
I've checked the [Enable SQL Server debugging] in all my projects in the solution.
My projects:
ASP.NET web app
DAL class library. (The DAL uses a legacy .dbml to generate SP calling wrapper code.) No OR mapper neither direct ADO.NET used in the project.
SQL Server 11.0.3153
I would like to debug my called SPs when debugging the C# code in VS. Ideally it should step in to the SP, but if this is not supported, then break in the SP on a set breakpoint.
Unfortunatelly it does neither. If I set a breakpoint in the SP, it is not a filled red circle, instead an unfilled, which is not a good sign. (I am setting this breakpoint in Server Explorer, by opening a data connection, and opening the SP in the VS editor.
What am I missing?
General instructions, based on my experience and research.
Run Visual Studio (community version, in my case) as Administrator (for me, debugging a stored proc from VS only works when VS is run as an admin)
Go to the Solution Explorer, right click on your project and go to properties.
Click on the Web tab and make sure that SQL Server is checked. Save and close.
Click on the View menu, then on SQL Server Object Explorer.
In the SQL Server Object Explorer, expand SQL Server and if you don't see your SQL Server, right click on SQL Server and add it.
Right click on the SQL Server that you just added and make sure that both Application Debugging and Allow SQL/CLR Debugging are checked.
Expand your SQL Server instance that you added and find the stored procedure of interest.
Right click that SP and click View Code.
Put a break point where you wish.
Run and enjoy.
You may have to do some of these things next time you wish to debug a stored proc from VS after you close VS and open it up later.
I had the same problem...
In the "Solution Configurations" dropdown, the selected configuration was "Debug (Active)". I changed that to "Debug."
After the change was made, the debugger worked normally and the "Debug (Active)" option disappeared from the list.
Previously I developed everything DB related in SSMS but since I didn't have it setup with any source control I decided to move it into Visual Studio (where I develop everything else) as a Database Project.
This works quite well for most things but I would like to test and debug my stored procedures somehow without publishing the project. Is this possible and how is it done? The important thing is that data from the production DB should be accesible for the stored procedures.
From Visual Studio, open SQL Server Object Explorer (View-SQL Server Object Explorer). Find your database, right click and select "New Query".
You can run/test your sp using "exec spProcedureName".
You can use "Ctrl-Shift-E" as a shortcut to execute query.
Also, you can find your procedure under "Programmability-Stored procedures" and right click on it. If procedure has parameters, you'll get a pop-up window in order to enter params.
I have a scripted database SQL file that I need to execute inside Visual Studio to create a new database. I am so far unable to locate any function that allows me to do this.
Go to server explorer in VS, right click on server and select run query.
Do you mind telling us why it has to be run inside VS?
In addition, the database projects offers a lot of features that are worth looking at:
http://www.informit.com/articles/article.aspx?p=31764 //old article but still worth reading.
http://www.ssw.com.au/ssw/standards/BetterSoftwareSuggestions/Images/VisualStudio_DataDude_SchemaCompare.gif
http://www.emadibrahim.com/2008/07/10/database-schema-compare-upgrade/
There is a green arrow of play on the upper left corner of the window query. And down the tabs of the names of open files in VS. Just click to play and ready.