
Find Tables with an XML Column
You can find tables with an XML column in the following way: SELECT [table] = s.name + N’.’ + t.name FROM sys.tables AS t INNER JOIN sys.schemas AS s ON

You can find tables with an XML column in the following way: SELECT [table] = s.name + N’.’ + t.name FROM sys.tables AS t INNER JOIN sys.schemas AS s ON

You can refresh a database object with the help of the sp_refreshsqlmodule function, as shown below: EXEC sys.sp_refreshsqlmodule ‘ObjectName’

You can write “not equal to” in two different ways in SQL: !=

You can obtain the oldest Open Transaction in the following way: — Create temporary table for results. CREATE TABLE #OpenTrans ( CurrTrans VARCHAR(25), CurrTransDet SQL_VARIANT ); — Insert info in

You can force a like condition to compare only alphabetic values. Here is how: ORDER BY CASE WHEN LTrim(RTrim(Place.Name)) NOT LIKE ‘%[^0-9]%’ THEN 1 ELSE 2 END, Place.Name

You can fetch records that are common to one or more tables by using INTERSECT. Here is a small example: Select * from EmployeesIntersectSelect * from RetiredEmployees

SQL Server, by design, caches query plans for queries. For reuse of cache, the best practice would be to include the schema name in the query. For example: select *

Setting a default NULL Date in SQL is quite easy, you just need to concentrate. A statement similar to the following will convert any NULL value inside the specific DATE

Dramatically reduce the execution speed of your queries using SET ARITHABORT ON as it saves time by not calculating unnecessary numerical data.