How to debug stored procedures in SQL Server 2018 - sql-server

How can we debug stored procedures in SQL Server 2018? As SQL Server 2018 and above versions do not have this option. Debugging makes life really easy. I have been trying to solve one problem for past one hour and if I could debug my stored procedure, I could have definitely save a lot of time. I did search a lot and did not find anything useful that could work.
Please do let me know if there is any way. Thanks.

How can we debug stored procedures in SQL Server 2018?
There is no such product as "SQL Server 2018" - I assume you're referring to one of the following:
SQL Server 2017
SQL Server 2019
SQL Server Management Studio 18
If you're referring to SQL Server 2017 or SQL Server 2019 then you can debug Stored Procedures by either:
Using SQL Server Management Studio 17.
Which may not work when connecting to a SQL Server 2019 instance, so YMMV.
Using SQL Server Data Tools (aka SSDT).
This is currently the officially supported tool for debugging SQL Server procedures and other objects in SQL Server.
SSDT is included in the free-as-in-beer Community Edition of Visual Studio without restrictions on its use in commercial settings.
But SSDT is not in any way a replacement for SSMS: SSDT only has basic tools for administering running SQL Server instances. So you'll need both SSMS and SSDT installed side-by-side.
If you're actually referring to SQL Server Management Studio 18 then you cannot debug procedures in SSMS 18 because Microsoft removed the feature for reasons unknown - I suspect perhaps involving the usual vague business reasons the veeps hand-wave with - because I cannot fathom any seriously good reason (though I agree the tooling was clunky, it did work at least).
To debug a procedure with SSDT you need to install Visual Studio (2017, 2019, they all have it) and select SSDT during VS installation. In previous releases of VS (like 2012, 2013, and 2015) SSDT used to be a separate download for VS but since VS 2017 it's part of the main installer.
When VS opens, dismiss the Start Screen and get to the main window, and go View > SQL Server Object Explorer, then connect to your server and the rest should be familiar to you.
As it sounds like you already have a substantial database project that exists in an extant SQL Server instance but also that you are not currently using SSDT - so I recommend you take this opportunity to actually move your project out of SQL Server and into an SSDT *.sqlproj - that way you can manage your database's design with source-control (Git, etc) and do local "builds" of your database (which will verify your code is valid T-SQL, it's saved me a lot of stress and trouble since I started using SSDT over 12 years ago) - it also makes publishing, deployments and schema changes a breeze (except for the fact the SSDT seems to get buggier and develops new glitches with each new release, ugh).

Related

SQL Server Reporting Services (SSRS) installation and configuration?

I have installed SQL Server 2014 and Visual Studio Professional 2015. So, does that mean it already has SSMS pre-installed with it, or it needs to be done separately.
My need is: Report generation using SSMS, from data coming from query behind SQL Server.
So, what needs to be exactly done to configure SSMS into SQL Server with VS 2015.
Upon deep diving even more, got the answer.
Option One: Google for 'SQL Server Data Tools' installer, compatible with your VS. Run the Installer.
Option Two: Open Visual Studio 2015 - Tools > Extension and Updates. Find/Search for 'SQL Server Data Tools' update option. Run it.
I'm still not sure if there comes a complete package of Visual Studio along with Data Tools, but I don't think it does. As we still need to add certain packages into VS Installer as per need.

SQL Server Compare Schema in Visual Studio 2017

I am attempting to compare schemas of two databases on the same server.
The two databases are named benchmarkdb and benchmarkdb_dev.
In Visual Studio 2017, I go to Tools > SQL Server > New Schema Compare...
From both drop down menus labeled "Select Source" and "Select Target" (as seen in the picture below), I want to select benchmarkdb as source and bencmarkdb_dev as target.
After clicking to select a source, the "Select Source Schema" pops up, and I clicked the "Select Connection..." button, which brought another popup. The newest popup (the one on the right in the picture below) shows both databases I am trying to compare.
However, after I choose one for either the source or the target, all pop ups close, but nothing populates the "Select Source..." or "Select Target..." drop down menus. In fact, it just goes back to looking like the first picture.
Is there a solution to this so I can compare the schemas between the databases?
Update:
I have tried this on VS 2012, 2015, and 2017. All are facing the same issue. VS software and system software are up to date. Below are some versions of software that I am using, if it is any help.
Windows 7 Enterprise SP1
VS 2012, 2015, and 2017
SQL Server 2014
.NET Framework v4.7.02053
OK, so I managed to fix it.
First off, you need to install SSDT from Microsoft pages. Just google it.
Make sure that you also have it listed in individual components when starting Installer (on Modify). Only SQL Server Database is required (I could choose from Integration Services and 3 more).
Next, you need to "Remove connection from history" in Schema Compare modal for connection selection.
I closed VS at this point, to make sure that the connection is not in history anymore.
Starting VS the next time, you should not have the problematic connection in history.
Recreate the connection (I checked "remember password") and voila. Schema compare works.
Not really sure, but in desperation I also installed "Redgate ReadyRoll Core", "Redgate SQL Prompt Core" and "Redgate SQL Search".
I don't think it matters, but if all else fails...
Edit: This worked on 2 machines and it doesn't seem to be connected to VS version.
I had the same issue, but I don't know if I had the same root cause.
My problems started after changing my database from SQL Server on a Window Server to SQL Server on a Linux Container. The schema compare would appear to accept my selection but the database field would never actually populate and I could not perform a comparison.
There were 2 things I had to do to solve the problem.
Update Visual Studio (using the standard updater within Visual Studio).
Update the SQL Server Development Tools (SSDT) add-on for Visual Studio to a preview version that supports SQL Server on Linux. That download is available here.
After both updates were in place I could select the database and execute Schema Comparisons between my project and SQL Server on Linux exactly as I had been doing for SQL Server on Windows.
If running a local database, check what version of SQL Management studio you are using
I had the same issue running Visual Studio Pro 2017 and SQL management studio v18.6 with SQL Server 2017 installed.
I tried all of the above solutions and no luck
Even going back to Visual Studio 2015 didn't work for me. What did work though was changing back to SQL Management Studio v17.9.1
No issues any more.
I may try to upgrade Visual Studio to 2017 again to see if that works now

Index GUI Issues with SSMS 2014 and 2016 when working with SQL Server 2005

We currently work with all versions of SQL Server from 2005 onwards. To save time I try to do everything in a single version of Management Studio. This also helps if running newer client operating systems like Windows 10 which old client tools aren't compatible with.
Specifically when trying to view the graphical SSMS interface for index properties I get the following error if connected to a SQL Server 2005 instance.
In Object Explorer:
Database > Table > Indexes > Right Click > Properties
Full error text:
TITLE: Microsoft SQL Server Management Studio
Exception has been thrown by the target of an invocation. (mscorlib)
ADDITIONAL INFORMATION:
Cannot read property IsSparse. This property is not available on SQL Server 2005. (Microsoft.SqlServer.Smo)
This also happens in SSMS 2014, but not SSMS 2012.
So my question is; can something be done to work around this issue allowing one version of management studio to be used for all versions of SQL Server from 2005 onwards?
I'm guessing now, but as it works in SSMS 2012 there must be something going on that targets an older version of mscorlib. Maybe because SSMS 2012 uses a VS2010 shell and different .Net framework?
Many thanks in advance for your time.
There is an Active feedback about that on Microsoft Connect here. Someone suggest a workaround to go into Table Design and go to menu "Indexes/Keys...". It works, but some properties are not editable that way, like Included Columns. The other options left are to use SSMS 2005-2012 or use T-SQL script, like Aaron said.

Best suitable SQL server for VB 8 Express Edition?

I am about to start a project on VB.. For that I am using Visual Basics 2008 Express Edition.. So I just wanted to know which is the best suitable SQL Server for the same.
SQL Server 2008 was released alongside VS 2008, so one of its variants would be recommended. The Express Edition will work well. If you want to use User Instances (such as when the database file is stored in an App_Data folder for a website, you need to have Express Edition installed. In addition, if you plan to use any data related projects in an actual production environment, but don't want to spend, it's the only option that's freely available.
Of course, you might want to consider the age of the product. VS 2008 itself is 2 generations behind (at present, Jan 2013), as is SQL Server 2008. You can easily use later editions of both SQL Server and Visual Studio (in there Express Editions), and I'd usually recommend moving up to the latest that's installable on your machine.
If you're wanting to try out all of the SQL Server features, a trial installation or Developer Edition would be recommended - but for the latter, you need an MSDN license, and if you're going that far, you should seriously consider moving up from VS Express.
Microsoft SQL Server 2008 R2 hands down. It's free and you can use stored procedures, functions and such.

Write a plugin/form for SQL server enterprise manager

Is it possible to write a plugin or a form for SQL Server Enterprise Manager version 8? I'm doing some simple queries all the time to admin the databases. So wondering if I could write something for it.
You mean the old SQL Server 2000 Enterprise Manager?? I don't think that old clunker had any extensibility points, sorry....
SQL Server Management Studio (SQL Server 2005 and newer) is based on Visual Studio and thus does have some extensibility - but it appears to be somewhat of a black art to write such a plugin - very little information is available.
Some is here:
The Black Art of Writing a SQL Server Management Studio Add-In
Building a SQL Server Management Studio Add-In
Extend Functionality in SQL Server 2005 Management Studio with Add-ins
SSMS Scripter - Internals, part 2 - plugging in
Since I usually do all my work in a query window, I just use a bunch of custom written stored procedures that I made, passing in parameters as necessary. all of my redundant work is done this way.

Resources