Click here to Skip to main content
15,885,546 members
Everything / SSMS

SSMS

SSMS

Great Reads

by Mashudu Nemukula
Generate C# object class from common SQL databases types
by Stefan Timovski
Tutorial on how to start developing SSMS extensions
by Kuv Patel
Debug stored procedures in Visual Studio and SQL Server Management Studio.
by Vivek Johari
Migrating SQL Database to Azure SQL Database using SSMS Export/Import Contents

Latest Articles

by Federico Di Marco
spSearchTables: a helper T-SQL stored procedure for digging into (large) databases
by Federico Di Marco
Query Excel or CSV files with T-SQL without importing them in a table first
by Vadim Loboda
This is an alternative for "VS2010 Box Selection with Copy and Paste"
by Harinder Saluja
Implement Neural Network in SQL Server

All Articles

Sort by Score

SSMS 

11 Jun 2021 by Mashudu Nemukula
Generate C# object class from common SQL databases types
9 Jun 2019 by Stefan Timovski
Tutorial on how to start developing SSMS extensions
18 Feb 2016 by Kuv Patel
Debug stored procedures in Visual Studio and SQL Server Management Studio.
19 Nov 2018 by Vivek Johari
Migrating SQL Database to Azure SQL Database using SSMS Export/Import Contents
21 Nov 2023 by Federico Di Marco
spSearchTables: a helper T-SQL stored procedure for digging into (large) databases
3 Feb 2015 by Suvendu Shekhar Giri
Exciting SSMS features derived from Visual Studio
5 Feb 2015 by Suvendu Shekhar Giri
In this series of posts, we’ll see few great yet less known and under utilized tips/features that are there since earlier versions of Visual Studio and later made their way to SSMS (SQL Server Management Studio).
31 Jan 2017 by saddam_msp
Shortcuts to execute your query faster while working or debugging T-SQL statement
2 Nov 2019 by Ghanshyam N Patel
How to shrink SQL Server database log file
15 Apr 2015 by OriginalGriff
That's because it's a bad idea! :laugh:Firstly, you shouldn't store dates as strings: you should always store them as DATE or DATETIME instead - and they don't have a format, they are stored as the number of microseconds since an arbitrary point in time. Storing dates as strings is both...
17 Oct 2018 by User-12551084
Moving database file from one drive to another drive
25 Nov 2018 by Vivek Johari
This post discusses how to migrate SQL database to Azure SQL database using SSMS deploy.
2 Jul 2021 by Kevin Chadney
Creating a simple SSMS extension which accesses the query window and object browser.
26 Jul 2023 by CHill60
This is the same question as How to find maximum of date if group ids (particular group) present, else latest date where all group ids present[^] I have already provide a solution to that post giving exactly the results you said you wanted. ...
7 Apr 2015 by Richard Deeming
At a guess, you forgot to set e.Cancel = true in the RowUpdating event handler. As a result, the GridView is calling the UpdateCommand on the associated DataSource control after your code has already called the same command.EDIT: You'll also need to set the EditIndex to -1 before re-binding...
15 Apr 2015 by Richard Deeming
As Griff said, don't store dates as strings, and avoid formatting values in the database layer.However, if you absolutely have to format a date in the database layer, and you're using Microsoft SQL Server 2012 or later, you can use the FORMAT function[^]:DECLARE @D date =...
15 Jul 2015 by Wendelius
This is based on a (faint) memory but if I remember correctly, when you define multiple devices, it means that the backup is distributed on those media. Based on that you should use only one media on the restore since you have all the data in one file.However I believe that it would be...
7 Oct 2015 by Richard Deeming
If you read the documentation[^], the reason would become clear:OPENQUERY (Transact-SQL)[^]:'query' Is the query string executed in the linked server. The maximum length of the string is 8 KB.You'll need to find a different way to do what you're trying to achieve. For example, you could...
25 Aug 2016 by Sys Dev
Found the solution thru trial and error. I reinstalled MSSQL2K as a default instance instead of installing them both as named instance as I previously did. Still, thanks for the feedback guys! :)
3 Sep 2016 by OriginalGriff
It means it's based on Visual Studio Isolated Shell[^] rather than written as a unique stand alone product.
18 Sep 2017 by OriginalGriff
I always install SQL server first, then Visual studio - the reason is that VS uses SQL, so if it's already installed, it doesn't add it's own version. I've had problems with VS before after installing SQL "over the top" of it. SSMS installs as part of SQL Server, so that shouldn't be a problem.
10 Sep 2018 by Manjuke Fernando
How to give db_datareader access to a specific user across all the databases on a particular SQL Server
20 Nov 2018 by CHill60
Solution 1 has corrected the two fundamental errors in your code but has not made it particularly clear especially by moving the ORs. Here is the fix for the syntax errors you are generating. In your WHEN MATCHED clause you have TARGET.[PartNote] SOURCE.[PartNote], It should be ...
3 Aug 2020 by Garth J Lancaster
The only thing obvious I see is ZIP, (the trailing comma) You could also fully qualify [dbo].[VISION_SALEHIST2] ie [SomeDatabase].[dbo].[VISION_SALEHIST2] in both occurences
7 Sep 2020 by Maciej Los
I'm not sure i understand you well... You need to split @SPInput by {'|', ','} to get [Type] and [Value]. Then you have to compare that values with the values in a table. See: DECLARE @tmp TABLE(ID int, CustomerID int, [Type]...
16 Apr 2021 by Richard Deeming
Try replacing: cmd.Parameters.Add($"@p{i}") with: Dim p As SqlParameter = cmd.CreateParameter() p.ParameterName = $"@p{i}" cmd.Parameters.Add(p)
29 Dec 2021 by OriginalGriff
Unless your table includes a "InsertedBy" column that identifies the user when the INSERT operation is made, it's complicated, and will depend on the database system and the way it is used by you. If it's a multiuser DB system like SQL Server or...
23 Jan 2022 by M Imran Ansari
Values in table with bit datatype will store as 1 or 0 and on retrieval you can get with the CASE statement. Query is written below: SELECT CASE WHEN [IsActive] = 1 THEN 'TRUE' ELSE 'FALSE' END [IsActive] FROM [dbo].[Users]
23 Jan 2022 by OriginalGriff
We can' tell - it needs your code running with your database, and we don't have access to either. So, it's going to be up to you. Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you...
8 Feb 2022 by Richard Deeming
This is not a bug; it's a feature called "deferred name resolution". Watching Out for Deferred Name Resolution – SQLServerCentral[^]: You may be wondering why SQL Server lets you do something so stupid, but there is a good reason. Many stored...
17 Jun 2023 by Mike Hankey
See this article Space in the column’s name[^] You might need to put the column name in brackets like below; use DemoDatabase go /*Query with square bracket*/ select [country code], [country name] from tblCountries Go /*Query with double...
1 Aug 2014 by Chris_Yates
When managing a large amount of servers and databases, having an efficient way to search for objects in a particular database, SQL Server instance or the object metadata is crucial. DBA Chris Yates tells us why SQL Search from Red Gate helps him achieve this with ease, and at no cost.
19 Feb 2015 by Wendelius
Well you could try the following indices:CREATE INDEX ReportingAcxiom_campaign ON ReportingAcxiom (campaign);CREATE INDEX ReportingAcxiom_campaign ON ReportingAcxiom (campaign_id, cell_id, campaign);CREATE INDEX master_campaign ON master (campaign);CREATE INDEX ecampMatch_campaign ON...
19 Feb 2015 by Wendelius
I'm adding another solution since a completely different approach would be to squeeze the logic into a single statement. If I didn't make too many mistakes, it should look something like with a as ( select campaign_id, Campaign_desc, CONVERT(VARCHAR(19), max(Campaign_start_date),...
27 Mar 2015 by Andrew Augustino
I have a stored procedure which I use to update data through GridView RowUpdating event. What a stored procedure does is that it update a certain record first and then it create another record after successfully update. What happens now is that the first record is updated successfully and then...
2 Apr 2015 by saad88
Hi all Just want to right a stored procedure, that will read six column from .txt file and then insert into temp table , than i have to do some transformation on data , than i want to write this data back in to four files so i have a column whos values are A,B,C,D so i have to write 4...
15 Apr 2015 by saad88
Hi Alli have a date format like 20150414 , and i want it to change it to 14 avril 2015 , so basically in french in stored procedure , anyone can tell me as i think there is no standard in ssms for it any help would be much appriciated Thanks
17 Apr 2015 by Sandeep Mogaveer
Hey,I've two set of codes which might help you to resolve the issue.First one is to read the Data from a Text File.--Create a linked server.EXEC sp_addlinkedserver txtsrv, N'Jet 4.0', N'Microsoft.Jet.OLEDB.4.0', N'c:\data\', NULL, N'Text';GO----Set up login...
15 Jul 2015 by Sander Rossel
Hi all,I'm having a little trouble restoring a database backup.I've got the following queries for backing up my database:-- Full backup every night at 01:00.DECLARE @FileName VARCHAR(256)SET @FileName = 'C:\Backups\mydb_backup_' + CONVERT(VARCHAR(8), CURRENT_TIMESTAMP, 112) +...
7 Oct 2015 by Ragul M
Below sample sp's are based on my working sp's, i have made this easier for you to understand in a simpler way to find the solution.1) First SPCREATE PROCEDURE testsp@doc varchar(max) ASDeclare @idoc int EXEC sp_xml_preparedocument @idoc OUTPUT, @docSELECT * FROM OPENXML...
4 Nov 2015 by Member 0123456789
I've installed SQL Express 2014 with all of its tools and created a instance (SQLEXPRESS) with Windows Authentication. Then I created a table named dbo.doc in the master database with 18 columns and entered 7731 entries in it. I started a new Windows Form Project in Visual Studio Express...
4 Nov 2015 by Mehdi Gholam
There is an overhead to "data binding" and showing the rows in the UI.To check this time the da.Fill(dt) only without the data binding to UI elements. (as a side DataSets and DataTables are also slower than direct queries because of the object structure).
21 Nov 2015 by Member 11366322
I have a Business Requirement. I have lots of text files in a folder location. Say for an example: **Sales_Newyork_1102_2012.txt****Sales_Texas_1102_2012.txt****Sales_Dallas_1102_2012.txt**.I need to insert all these files to tables similar to the file structure....
21 Nov 2015 by George Jonsson
There are some articles out there you can readHere is one SSIS - Import Text File[^]Here is another one: Loop through Flat Files in SQL Server Integration Services[^]On a side note. Depending on how large the data you have is, it might be better to consider to use one table and add a...
17 Dec 2015 by Member 11820531
I've created a temp table using the following code: if OBJECT_ID('Tempdb..#FormerMajor','U') is not null drop table #FormerMajorCREATE TABLE #FormerMajor (ID int IDENTITY(1,1),MyID varchar(11),LastName varchar(9),FirstName varchar(9),PKey int,CurrentInfo...
17 Dec 2015 by Tomas Takac
You most not insert values into the identity column, this value will be assigned automatically. But to leave out the one column you need to specify the full list of columns you want to insert:INSERT INTO #FormerMajor (MyID, LastName, FirstName, CurrentInfo, SourceKey, Term, PKey) select...
30 Dec 2015 by 23741
The marginal propensity to consume is directly related to disposable income.The marginal propensity for me to do your homework for you is directly related to the amount you pay me over 200$ per hour (USD).
1 Feb 2016 by Deepak A S
23 Feb 2016 by Member 11820531
I have a team group parameter in my SSMS stored procedure. The team group parameter has 4 values. So far this is what I've coded:Declare @Param1 int = 1,@Param2 varchar(4) = '1169',@TeamGroup varchar(150) = 'RCBE,RLEG,RPEN,RSPC'-- Code below supports multi-select in reportif...
23 Feb 2016 by ZurdoDev
There are many ways to do it; however, one easy way would be to do something like this:SELECT value FROM HEA.Parselist(@TeamGroup, ',')UNION SELECT teamFROM TeamGroupsWHERE @TeamGroup = 'All'That would union in all your teams if @TeamGroup was a keyword of "All"
26 Apr 2016 by Member 11820531
In my query I have a select statement that looks as follows: SELECT CAST((mt.SampleTotal * 100) / (mt.PopulationTotal * 100.0) as numeric(7,2)) as 'Column %'That statement returns .14 My user however wants to see the answer returned as 14 (a whole number).Is there a quick fix for...
26 Apr 2016 by OriginalGriff
Remove the multiplier at the bottom?SELECT CAST((mt.SampleTotal * 100) / mt.PopulationTotal as numeric(7,0)) as 'Column %'
2 Jun 2016 by Brian C Hart
Hi all,I am going to submit an Azure support ticket; however, in the interests of saving time, I've instead wanted to first try Google search and asking questions on Code Project and Stack Overflow.I am using an azure db and SSMS. It does not seem to matter which version of SSMS i am...
3 Aug 2016 by Member 11820531
I'm leaving out much of my sql to consolidate my question. I have a temp table declared as follows: if OBJECT_ID('Tempdb..#RankCalendar','U') is not null drop table #RankCalendar CREATE TABLE #RankCalendar(ID INT identity(0,1) ,CalendarDate DATE)INSERT INTO...
3 Aug 2016 by Dave Kreskowiak
You can "reset" the identity column by executing this SQL statement: DBCC CHECKIDENT ('tableNameGoesHere')If you want to reseed the column to a known value, you can use: DBCC CHECKIDENT ('tableNameGoesHere', RESEED, value)The next record inserted into the table will get whatever...
3 Aug 2016 by Richard Deeming
Would something like this work for you?if OBJECT_ID('Tempdb..#RankCalendar','U') is not null drop table #RankCalendar; CREATE TABLE #RankCalendar( ID INT NOT NULL, CalendarDate DATE NOT NULL);INSERT INTO #RankCalendar( ID, CalendarDate)SELECT ...
25 Aug 2016 by Member 11820531
I'm attempting to create documentation from our groups ReportServer database. I've found a few instances of the ReportServerDB. However, they're other server which the database lives on.What I have tried:I've tried pinging the reporting services browser and then performing an nslookup to...
25 Aug 2016 by Sys Dev
Hi, I have installed SQL server 2012 on my current machine as backend for new systems projects that are lined up for my company. However, I also need to support legacy systems that is using SQL Server 2000. I have seen threads stating that there would be no problem as long as I am using named...
25 Aug 2016 by The Praveen Singh
Go through msdn LinkWork with Multiple Versions and Instances of SQL Server[^]
25 Aug 2016 by Maciej Los
As per MSDN documentation[^], you cannot install MS SQL Sever 2k on the same machine where MS SQL Server 2k12 is installed.If i'm not wrong, your company can use MS SQL Server 2012 Express version for free. Check this: Download Microsoft® SQL Server® Express License Terms for Redistribution...
31 Aug 2016 by Member 11820531
Example of Column I'm trying to modify: | Column 1 | asdf sixsix =IWantToReturnThisIn1Column; asdfasd seven12=IWantToReturnThisInColumn2 I want to capture the contents between = and ; for col1a and capture...
31 Aug 2016 by Member 11114915 - Tanvi
SELECT SUBSTRING(col1, 14, 26) AS Col1, SUBSTRING(col2, 17, 26) AS Col2FROM colThis query will bring the desired result.Query Result: Col1 Col2IWantToReturnThisIn1Column IWantToReturnThisInColumn2Above can also be achieved by using CHARINDEX in case...
31 Aug 2016 by Patrice T
I guess the text length is variable, so you need to build a little complicated formula.I let you deal with details like declaring the intermediate variables or combining all this in large formulas without formulas.SC= INSTR(d.column1, ";") -- position of ';'EQ1= INSTR(d.column1, "=") --...
3 Sep 2016 by Suvendu Shekhar Giri
I am not sure but seems the SSMS since the Denali version, one can notice the bottom line "Powered by Visual Studio" in the splash screen that appears just before the login screen appears when you start SSMS. Now my question is, can any one provide the link to the official blog or...
5 Sep 2016 by Luiey Ichigo
Hi,How do I develop a program to compare data on schema? Currently, I'm using a Visual Studio Data Comparison which I see the comparison was very fast and include of matching each data.How to code for SQLDataCompare as the tools using C# or VB.NET? I would like to run it as program and...
5 Sep 2016 by NaibedyaKar
There is a SQL compare tool from Redgate that you can try. Of course it is not free. You might check the trial version of it.If you really want to do it pro grammatically, then I would recommend you to use JOINs. That might be little efficient for you. Else I afraid you have to load 2...
5 Sep 2016 by Maciej Los
Whatever you mean by "compare data on shcema", i'd say it isn't simple job. Check this: CodeProject Knowledge Base[^]
15 Oct 2016 by Mehdi Gholam
You can always create new databases for each year whenever you want, it depends if your users require to query for data over a year time period or not (querying multiple years from different databases into one result can be problematic).Breaking up your data into years (into different...
15 Oct 2016 by Wendelius
There are a lot of affecting factors. Some thoughts:Having the completely different schemas in different databases would make sense. Especially if you consider licensing only parts of the product, a modular approach would make licensing easier. For example you can buy only accounts module...
1 Jan 2017 by RAFish0404
Hello,I have a small database (.mdf)file which I attached in SSMS so that I can see the tables in the Object Explorer. However I am unable to create Database Diagram for this database and I receive and error each time I attempt to do that. So I can't establish any relationships or perform...
1 Jan 2017 by Suvendu Shekhar Giri
Try giving a database owner to your database. That resolves the error for me in the past.If you still get error, please check following threads, if these help resolve your issue -sql server - Cannot execute as the database principal because the principal "dbo" does not exist - Database...
31 Jan 2017 by CHill60
It might have been best if you had just typed in what your homework assignment said because you didn't explain it very well.However, first problem - you are using Partition By for the quarter, but you also need to partition by the CustomerIDSum(TotalDue) Over (Partition By CustomerID,...
21 Feb 2017 by manjiriV
Quote:i know how to find duplicate values using count() but my question is how can i find duplicate values starting with some letter like'A' or 'K'i have a table tblmytable like thisid rollnumber city fess 1 A100156 Ajamer 450 2 P102555 Pune 450 3 A100156 Ajamer 450 4 P102555...
2 Aug 2017 by Member 11820531
I'll start with what I'm trying to accomplish: - I have a current and historic table. - I want to check if the same customer in both tables, has ever had a reason_iden_fk = 1. - If they have a record in both tables I'd like to take the later of the 2. - How can I force the most recent...
2 Aug 2017 by Kornfeld Eliyahu Peter
If you are interested in the latest date (either form current or archieved table) UNION can not help you... UNION will remove duplicates, but for latest date you will have to do a JOIN between the tables... Something like this: select * from table1 left join table2 on table1.customer =...
18 Sep 2017 by Member 13415725
Error while installing SQL Server 2016 Developer Edition on a laptop that has Visual Studio 2017 Community version What I have tried: I installed Visual Studio 2017 Community version and then SQL Server 2017 successfully. While installing SSMS - I got some compatibility error. After that I...
25 Apr 2018 by Jamie888
Hi I have just installed SQL Server 2017 Express LocalDB recently. But when i try to connect to it using SSMS, it prompt me "Cannot connect to (LocalDB)\." error. I have tried to search for the localDB installed in control panel's programs and features and it is there. Anything i missed? Thank...
25 Apr 2018 by Richard Deeming
You need to use the SqlLocalDB Utility[^] to create and start a LocalDB instance before you can connect to it.
7 Jun 2018 by OriginalGriff
No, we don't do that. We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. Try it...
7 Jun 2018 by Patrice T
Quote: can you give me the query to finish this question please.... i dont even understand about this question iam still newbie The one you need to talk to is your teacher. HomeWork problems are simplified versions of the kind of problems you will have to solve in real life, their purpose is...
13 Jul 2018 by Sandeep Vemulapalli
I have one question on the TSQL Linked Server Query. Linked Server is GIS enforced so we pass the coordinates to that server which it returns the data from the Linked Server. Please find the below-working query. DECLARE @input varchar(max), @sql varchar(max); SET @input =...
13 Jul 2018 by Gerry Schmitz
Your "before and after" single quotes "changed". You need to "simplify" your string handling so you get a better handle on what's happening. SET @b = geometry::STGeomFromText(''''POLYGON '+ @input + ' '''', 4326); SELECT @b = geometry::STGeomFromText(''''POLYGON ' + @input + @input2 + '' ',...
25 Jul 2018 by chenchen101
Hi All. I have created a simple VXIS add-in to SSMS 2017. I need to be able to add a menu item to the context menu of a table. Once I click this menu item, I want to display the table name (with DB and server). I can't find any reference regard events and handlers on VSIX command. Thanks in...
25 Aug 2018 by OriginalGriff
Take out "As" after the inner SELECT: SELECT a.X, b.Y from MyTable a JOIN (SELECT ID, x AS Y FROM MyTable) B ON a.ID = b.ID
27 Sep 2018 by Gatsby29
My hosting provider use sql server 2014 version and i have installed 2017 version on my laptop, can i make Management studio 2017 to use older version (2014) or do i have to delete this new version and install older? What I have tried: I have tried to change version in options but when i...
27 Sep 2018 by Alek Massey
On your database on your 2017 instance, you need set the compatibility level to match your 2014 instance's. View or Change the Compatibility Level of a Database | Microsoft Docs[^]
16 Nov 2018 by Member 14056986
I have a work assignment that consists of linking two databases on two different computers through SQL Server Management Studio. Basically, both databases have to transmit the same data to a centralized SCADA from some machines that have different tasks. What I am trying to do is making this...
19 Nov 2018 by #realJSOP
Create a stored proc that implements the business rules. Above and beyond that, you didn't specify anything resembling what you want.
20 Nov 2018 by MadMyche
I'll do a very simple proof of concept for you, as you gave us zero to work with. This should give you a place to start... you could replicate the SP as needed for doing different interval based inserts, just change your naming and the interval type as needed. First I'm doing a very simple...
15 Jan 2019 by Member 14109112
I want to create an extension (VSIX Extension with Visual Stduio 2015) for SQL Server Management Studio 2017. Unfortunately, I'm not really making any progress. Adding an item in the upper menu bar works fine. But that's not exactly what I want to do. I want to add an item or a submenu in the...
15 Jan 2019 by Richard MacCutchan
You should post your question in the forum at the end of the article, so the author can help you.
6 Mar 2019 by Melick
How to copy your production SharePoint database to development environment
12 May 2019 by Manjuke Fernando
Observations made for a strange behavior on JSON_VALUE when table contains blank and non-blank values
23 Aug 2019 by Virendra S from Bangalore, Karnataka
In my SSMS version 17.8.1 for null value background color is not showing, this feature is handy but missing in installed SSMS, how to enable this feature. What I have tried: In my SSMS version 17.8.1 for null value background color is not showing, this feature is handy but missing in...
23 Aug 2019 by OriginalGriff
It was a "feature" in some versions of SSMS released with 2008R2 and before: the NULL value was shown with the Windows Tooltip background colour. Since this was not acceptable to MS, it was removed: cannot change GridResults background color – Customer Feedback for Microsoft Azure[^] - scroll to...
8 Oct 2019 by MadMyche
OK, so we have a few problems going on here... SQL Vulnerability and Poor Password practices, which have been covered in Original Griff's answer[^], and I am not going to rehash these points. Code organization- you have a pretty good building of the INSERT statement, and then there is a SELECT...
3 Nov 2019 by Nishanth J
After reinstalling the Visual Studio Professional 2017, since then I used to get the error message as The application cannot start, while opening the Microsoft SQL Server Management Studio 17 I had repaired and reinstalled but still the problem exist. The application cannot start[^] What...
3 Nov 2019 by OriginalGriff
Contact Microsoft tech support: support.microsoft.com/[^] and explain to them. It's a known problem and they have solutions (or it was with SQL 2016): Visual Studio 2017 install breaks SQL Server Managment Studio 2016 - Developer Community[^]
27 Jul 2020 by pooher
Hi guys, I need to connect oracle and SQL server databases using ODBC by the following application. 1) Toad 2) SQL Developer 3) SSMS 4) CMD Is there a way to connect these applications thru ODBC. IF yes could you please help me with this. I...
3 Aug 2020 by GIS Mansfield
I have this query that I'm having some issues with. I'm using 2 MS SQL Server 12. I'm new to SQL. I'm trying to run a query to extract that data from the one server and bring it into another MS SQL Server 12 which hosts the tables that will...