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 – 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