Click here to Skip to main content
15,881,709 members
Everything / Database Development / SQL Server

SQL Server

SQL-Server

Great Reads

by Wonde Tadesse
This tip/trick helps to set a default value for blob data type such as Image, VarBinary.
by Jovan Popovic(MSFT)
Mapping properties in EF model to database columns that contain JSON
by Steve Krile
Fully AJAX-enabled user control used to select names from a database in a drop-down format.
by Mubin M. Shaikh
Create time dimension with 24 hour plus values and time buckets in your data warehouse

Latest Articles

by GabrieleTronchin
A simple stored procedure to add at your database to keep it reactive
by GabrieleTronchin
Automatic creation of non clustered indexes using system SQL entities
by yuvalsol
POCO generating application for SQL Server
by scastelli
SQL resolves special character challenges, streamlining NULL parameter handling

All Articles

Sort by Updated

SQL Server 

5 Jan 2011 by #realJSOP
You can also enclose your column name in brackets, like so: [Create Date]
26 May 2011 by #realJSOP
When all else fails, fire off some events and bask in the glow of the IDE's Progress tab.
31 Jan 2017 by #realJSOP
A scalar function to determine if a given DateTime is one of the ten US federal holidays, using SQL Server.
31 Jan 2017 by #realJSOP
Using common table expressions to build data from thin air.
22 Sep 2017 by #realJSOP
It doesn't always happen the way you expect.
16 Feb 2013 by 1Lam
Create the following table on a local database:CREATE TABLE [dbo].[TB_TEMP_TABLESTORE]( [SEARCH_STRING] [nvarchar](128) NULL, [DB_NAME] [nvarchar](128) NULL, [OBJECT_NAME] [nvarchar](128) NULL, [OBJECT_TYPE] [nvarchar](50) NULL) ON [PRIMARY]Rename Yourdatabase to the same...
12 Apr 2011 by __Untitled
Actually, we think xp_cmdshell is not safe enough, and need to be enabled using surface area configuration explicitly (SQL 2005). We use xp_delete_file instead, sample code:DECLARE @l_Runtime DATETIME, @l_BackupFileName VARCHAR(256), @l_FileExists INTSET...
25 Nov 2017 by A.Ebrahimi
Connect to local database on MS SQL Server in local machine and develop node.js code
27 Nov 2012 by Aadhar Joshi
Creating job in sql server which automates taking backup of all stored procedures and functions in physical drive.
17 Sep 2012 by aasim abdullah
Get all indexes list in detail, with their involved columns
1 Oct 2012 by aasim abdullah
How do you know, if someone disabled your job at production database server. Who is the calprit. How to send a mail alert for this change ??
19 Apr 2013 by aasim abdullah
Restore failure from Enterprise to Standard edition in SQL Server.
2 Oct 2012 by aasim abdullah
Using SQL Server Management Studio, have you ever come a cross following questions: Why every time, a new query window is open with MASTER database.? On opening SQL Server Management Studio, I need a new query window automatically ?
2 Oct 2012 by aasim abdullah
A simple query to get all databases size on a given instance.
19 Apr 2013 by aasim abdullah
Automatic query execution at every instance startup.
20 Oct 2012 by aasim abdullah
How to Refresh Intellisense Cache in SQL Server
19 Apr 2013 by aasim abdullah
The TOP clause is commonly used to get the top required rows from a result set. The beauty of this clause is that it can be used with the WITH TIES clause to retrieve all similar rows to a base result set.
23 Oct 2012 by aasim abdullah
How to use DELETED and INSERTED virtual tables to capture data change in result of any INSERT, UPDATE or DELETE statement.
24 Oct 2012 by aasim abdullah
Backup and then restore of a database is a normal job for developers and DBAs. This script will be helpfull to findout, from which path, and which backup file a database was restored.
1 Nov 2012 by aasim abdullah
A stored procedure can be called from another stored procedure as nested stored procedure. How to get a list of these stored procedures with their nested one
1 Nov 2012 by aasim abdullah
You have place indexes but still queries are slow... are you facing bookmark lookup problem ???
3 Aug 2012 by Abdul Quader Mamun
To traverse a table without cursor, you only need to add an additional field in the table with null value. Here is the code for traversing a table.
10 Feb 2012 by abdul sami
select aday, code, convert(varchar(5), min(atime), (108))MinTime, convert(varchar(5), max(atime),(108)) MaxTime from testgroup by aday,codeorder by aday asc
20 Jan 2010 by Abhishek Sur
It is a common issue of many of the guys on how we can fetch a record based on its record number. It is really easy to get first 10 records usingSELECT TOP 10 * FROM EMPBut when we want to fetch records in such a way say I need to fetch record from 40 to 50. This comes very handy when...
13 Sep 2014 by Afzaal Ahmad Zeeshan
A slight comparison of ASP.NET upon other (web) programming languages in the market and a discussion of me and some other (web) programming language developers.
12 Jan 2016 by AgarwalPriyanka, ErGauravSharma
Challenges faced in data migration testing
22 Nov 2011 by Ahmed Naqibul Arefin
How to backup and restore SQL Server database schema
23 Mar 2016 by Ahmet AYDIN
This post describes step by step how to run a Single Page Application template using ASP.NET Web API 2 and angularJS and how to use Web Application Project whose name is Dalyan.
18 Jul 2014 by Ajit Kumar Thakur Microsoft
This tip contains simple step by step solution to read SSAS cube data using MDX query and display in SSRS report.
11 Dec 2019 by Akmishra0719
Daily reminder using SQL Agent and SignalR
18 Jun 2010 by Alexander Konstantinov
Two stored procedures helping developers do less things when they create tables and indeces
27 Jun 2011 by Alexandros Pappas
This tool reads the descriptions of the columns of the SQL server and creates a Word document using SoftArtisans' WordWriter.
19 Sep 2013 by alifaraze
writing error in a text file is very easy but writing error from a custom assembly in reporting services requires permissions
6 Jun 2018 by Altaf Ansari
Dynamic creation of an SQL table by using an XML file, and importing data from an XML file to an SQL table.
30 Jun 2012 by Ameet Parse
This article describes How to find a Text in Stored Procedure (Checked on SQL Server 2008)
29 Jun 2012 by Ameet Parse
This is an alternative for "Find all Stored Procedures having a given text in it"
10 Dec 2013 by Amey A khedekar
A scenario with data type of the resultant select columns with UNION.
19 Apr 2011 by Amit Kumar Tiwari
Boost application speed and performance
29 Nov 2015 by Amit Singh Baghel
Saving Details Table Data (An HTML Table) in Database by converting it into a jagged array and passing it to a table type parameter
30 Nov 2010 by Andrew Rissing
You might want to do some further testing... It seems if you perform the following, the values are actually the same:SET NOCOUNT ONDECLARE @TMP TABLE( EmpName VARCHAR(50), Age INT)PRINT CONVERT(VARCHAR, GETDATE(), 121)INSERT INTO @TMP(EmpName, Age)SELECT 'Ravi Kiran',...
10 Mar 2012 by André Kraak
This is an alternative for "Finding numbers from a text in SQL Server."
17 Jul 2012 by Ani_0707
This article intends to describe a simple and elegant way of converting local datetime to UTC and store it in DB.
10 May 2015 by Ankit Bansal MVP
This articles explains the insertion of data into SQL Database using Stored Procedures with Output Parameters. Some Bootstrapping is also used to create a good looking HTML.
5 Mar 2011 by Anton Burtsev
Performing fast concatenation of strings from different records
28 Sep 2015 by Antonio Soares
This tip shows three alternatives (an intuitive and less efficient, a more efficient one and a third more efficient one) to count all rows of all tables in a database.
23 Aug 2011 by Anurag Gandhi
I have gone through a lot of examples to sort alpha numeric data in sql. Here is my way:
16 Mar 2012 by Anurag Gandhi
A Query to copy an individual table data between databases
1 Jun 2016 by Aqeeel
Identifying and deleting duplicate records from SQL Server Table
17 Jul 2017 by Arif H Shigri
This tip will discuss the difference between ROW_NUMBER(), RANK() and DENSE_RANK().
26 Oct 2014 by Arkadeep De
How to remove duplicate records using CTE in SQL
9 Mar 2016 by Arslan Elahi
Get the Comma Separated Value of one or multiple columns from SQL table
21 May 2014 by Arvind Singh Baghel
Import CSV or txt File Into SQL Server Using Bulk Insert.
26 Sep 2013 by Ashkan.hosseini
Stored procedure that generates insert stored procedure for tables
9 Mar 2011 by AspDotNetDev
I like the original solution, especially when compared to this (which I am posting just to show that there are other solutions):-- Initialize table.CREATE TABLE #BigStrings( StringID bigint IDENTITY(1,1) NOT NULL, StringValue text NOT NULL, CONSTRAINT PK_BigStrings PRIMARY KEY...
20 Jul 2013 by AspDotNetDev
This query will show you all tables and columns in a database, and it can be pasted into Excel for easy manipulation.
25 Aug 2013 by Atul_Kapoor
Steps for deploying Restart Health Check script in a SQL Server environment.
26 Aug 2013 by Atul_Kapoor
SQL Server Reporting database migration from SQL Server 2005 to SQL Server 2008 R2
3 Dec 2014 by Atul_Kapoor
Perform SQL Server Instance health check simultaneously on more than one server using Powershell
24 Jan 2014 by B. Clay Shannon
Create peace and unity in your organization by separating data and coding responsibilites
1 Apr 2016 by B. Clay Shannon
Save Excel (or other types of) files to SQL Server, then read them out again and make them downloadable via a link on an ASP.NET Web API page
29 Jan 2017 by Bart Ducal
Universal data change tracking solution for auditing SQL Server databases
5 Jun 2013 by Basavaraj P Biradar
How to find all the Stored Procedures having a given text in it.
25 May 2013 by Basavaraj P Biradar
GO Statement can also be used to execute batch of T-SQL statement multiple times
5 Jun 2013 by Basavaraj P Biradar
Difference between SQL Server Char and Varchar data type.
8 Jun 2010 by basementman
Or, assuming your table has an index, you could do this "old-school" as:select MAX(rows) from sysindexes where id = Object_ID('{tablename}')
13 Oct 2011 by bbirajdar
How to find duplicate values in SQL Server.
6 Nov 2011 by bbirajdar
Use of soundex() function in SQL server
1 Jul 2016 by bbsimonbb
World first implementation of the Dominic Strauss Kahn data access method!
28 Aug 2015 by Bert O Neill
AngularJS and Web API Active Directory Security (Authorisation)
8 Dec 2014 by Bertin @nonodata.com
It is often important to have general guidelines when putting together a Data Analysts Team.
20 Dec 2016 by BharatRamV
Finds the Best Table for a given set of columns
14 Jan 2016 by Bhishma Anil Kajaria
Browse and Copy data from your CSV file to SQL directly without any Windows application...
28 Sep 2014 by Bhushan Mulmule
This is terribly unorganized document with mix of MVC, Entity Framework, LINQ, HTML 5 and JQuery how tos...
9 Jul 2013 by Bhushan W. Juare
The different ways of retrieving XML data from SQL Server.
11 Jul 2013 by Bhushan W. Juare
This tip shows how to use SQLCMD utility in SQL Server 2008.
2 Dec 2012 by Bikash Karmokar
Connecting Windows Form Application With ADO.NET in C#
20 Feb 2012 by BillyGoatGruff
SQL Profiler is not included with SQL Express, this tip will help if you need to track client activity.
11 Oct 2011 by BlackburnKL
We use a slightly modified approach that returns results from more than stored procedures (although it could be modified to return only results for stored procedures). We use this code in a stored procedure that requires a parameter containing the text to search for.@StringToFind...
11 Jun 2013 by blnreddy
SQL Server built-in functions Coalesce()
17 Aug 2011 by bmckuhen
14 Jun 2013 by Bojjaiah
Single Stored Procedure for delete/retrieve all table of records
11 Oct 2013 by Brad Joss
A SQL String Split function for the real world
16 Oct 2013 by Brad Joss
Search your SQL code with simple T-SQL statements.
12 Mar 2014 by Brad Joss
Views to make analyzing SQL Agent Job statistics easier
17 Dec 2014 by Brad Joss
SQL CLR Functions for Zip Compression and Regular Expression evaluations
27 Jun 2012 by Brady Kelly
A quick and easy way to ensure that your Code First DB Initializer is always run when your app starts, not just on the first data access operation
22 Dec 2010 by Brian C Hart
Provides the quick-and-dirty syntax to connect to a given Microsoft SQL Server instance so you can then run a .sql query script against it, e.g., if you are calling this from code as part of a larger pipeline
20 Oct 2016 by Bryan Kowalchuk
The two most common database lookup table patterns are examined
17 Jun 2013 by C Is Sharp
PHP and Accessing MS SQL Server in Unix/Linux.
26 Jan 2012 by CaldasGSM
since syscomments is nvarchar(4000) the word may be split into several rows.. so you concat them.. or at least pair them up... here is the sp I use to search on the stored proceduresCREATE PROCEDURE [dbo].[sp_FindInProc] @sText NVARCHAR(MAX) = '%'ASBEGIN SET NOCOUNT ON ...
19 Nov 2020 by cattman1970
Function that consumes a Columbia Gas account number of 11+ digits and returns the check digit
2 May 2012 by Chamila Nishantha
Simple query to get table column name as rows
8 May 2012 by Chamila Nishantha
This tip describes how to add a running total column to a result set
30 Oct 2019 by Charles T. Blankenship
Backup and Restore SQL Server utility (where there is no SMSS onsite)
20 Jun 2012 by chetan dudhagara
How to Protect from SQL Injection in PhP based website
22 Jul 2015 by Chetan Naithani
Transforming dynamic row-level data into columns
4 Feb 2012 by chetan virkar
Uploading Zip File in ASP.NET
29 Apr 2013 by ChienVH
This article will show you how to implement Asp.Net membership into a new database