How can I create a linked server between a local SQL Server instance and an Azure SQL Database? This post explains hot to do : https://www.mssqltips.com/sqlservertip/6224/create-a-sql-server-linked-server-to-azure-sql-database/
Category: SQL Server
SQL SERVER – Convert a given date from UTC to your time zone and daylight savings time
Let's say you have a datetime value that you know is encoded in UTC (if you don't know what timezone your data was originally encoded in you're out of luck) If you want to convert the UTC datetime to Eastern Standard Time calculating the right daylight saving time, you can use on AT TIME ZONE 'UTC' and then … Continue reading SQL SERVER – Convert a given date from UTC to your time zone and daylight savings time
SQL SERVER – Copy more than 65535 characters from result grid Column
When you copy value from Result grid, data will be retrieved as per your Query options setting in SSMS ( Query -> Query Options -> Results -> Grid -> Max characters retrieved) Default characters value is 65535 and data copied from result grid is only of length 65535 If you want to increase maximum number … Continue reading SQL SERVER – Copy more than 65535 characters from result grid Column
SQL Server – How to identify blocking session
To indentitfy blocking session you can use sp_who2 system stored procedure. Below is sample code USE master GO EXEC sp_who2 GO
SQL SERVER – Troubleshoot high-CPU-usage issues
Good article that helps you to find the causes of high CPU usage in SQL SERVER : https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/performance/troubleshoot-high-cpu-usage-issues
SQL SERVER – Update top n records in sql server
This code willupdate first 100 rows of your table update top (100) table1 set field1 = 1
SQL SERVER – How to get last char in a string in sql server
select right('abc', 1) This will give "c" as result
SQL Server – Row Count for all Tables in a Database
Are you loiking for a SQL SERVER query that gives you an overview of how many row has every single database table? Look a this SELECT QUOTENAME(SCHEMA_NAME(sOBJ.schema_id)) + '.' + QUOTENAME(sOBJ.name) AS [TableName] , SUM(sPTN.Rows) AS [RowCount] FROM sys.objects AS sOBJ INNER JOIN sys.partitions AS sPTN ON sOBJ.object_id = sPTN.object_id WHERE sOBJ.type = 'U' AND … Continue reading SQL Server – Row Count for all Tables in a Database
SQL SERVER – Format numbers in SQL Server
Nice post that describes how to use SQL SERVER function to format numbers : https://www.mssqltips.com/sqlservertip/7021/sql-format-number/
SQL SERVER – Format Dates with FORMAT Function
Nice post that describes how to fomat dates in SQL SERVER https://www.mssqltips.com/sqlservertip/2655/format-sql-server-dates-with-format-function/