
How to Check for a NULL Value and an Empty String
You may need to check address fields (for example) for a NULL value or an empty string (the value looks null, but simply contains an empty string – which is

You may need to check address fields (for example) for a NULL value or an empty string (the value looks null, but simply contains an empty string – which is

Getting the inserted identity is quite easy in SQL. All you have to do is the following: SELECT IDENT_CURRENT(‘MyTable’)

STATISTICS IO?and STATISTICS TIME?show the amount of time spent on a query and the reads and writes of the query in question. This is good to know for quick performance

The following script can be used to print all column definitions for all the tables in your database. SELECTsys.schemas.name + ‘.’ + sys.objects.name AS TableName,sys.columns.name as ColumnName,CASEWHEN sys.types.name IN (‘char’,’varchar’)

Here is a quick way to find all currently blocked requests in SQL: SELECTSESSION_ID,STATUS,BLOCKING_SESSION_ID,WAIT_TYPE,WAIT_TIME,WAIT_RESOURCE,TRANSACTION_IDFROM sys.dm_exec_requestsWHERE STATUS = N’suspended’;GO

You can use the dm_exec_function_stats (in SQL Server 2016) to check detailed execution details of a function. These include: execution_count – the number of times this function has been executedlast_execution_time

A very common task is to backup a table’s data, but sometimes we’d just like to copy a table’s structure. This quick tip will demonstrate how to copy a table’s

The following query will enable you to list all the tables in your database that doesn’t have an IDENTITY Column: SELECT SysSchemas.name + N’.’ + SysTables.name FROM sys.tables AS SysTables

Use the following query to get the total number of rows for each table in your database: CREATE TABLE #TempTable ( [Table Name] [varchar](max), [Total Records] int ); EXEC sp_MSForEachTable