Browse by Tags

SQL Server TSQL to find complete CONSTRAINT information on a table catalog?
09 January 08 06:26 AM | SQL Master | 2 Comments   
I have had a requirement to see a detailed information about a constraint on a table that includes table fields, type, rules, referenced table and fields for FOREIGN KEYs, etc. Found this useful TSQL to get such information: SELECT k.table_name, k.column_name Read More...
SQL Server- TSQL to see which object reside under which file groups?
24 December 07 03:40 AM | SQL Master | 3 Comments   
To continue the FIND-FilegroupFull post on the filegroups, here is the most common question on the forums to get which object reside under which filegroup if there are multiple ones associated: select si.rows as 'Rows', SO.Name as Table, SI.name as 'Index', Read More...
Squeeze function
06 December 07 11:38 AM | Madhivanan | 2 Comments   
The Squeeze function is used to remove the multiple occurences of spaces into one occurence. In SQL Server there is no function to do the same. I needed to write this in my application to remove unwanted spaces in the string. Run the following and see Read More...
SQL Server 2000 - list the current Statistics names that exist on a table
05 November 07 08:00 AM | SQL Master | 2 Comments   
Using Query Analyzer you can list an execution plan for a query , where you can find/get any statistics that are missing for that query. So to see the create missing statistics you will get further information such as Statistics name and so on and further Read More...
TSQL to return internal table columns and column data types?
01 November 07 07:26 AM | SQL Master | 2 Comments   
SELECT SCHEMA_NAME(itab.schema_id) AS schema_name ,itab.name AS internal_table_name ,typ.name AS column_data_type ,col.* FROM sys.internal_tables AS itab JOIN sys.columns AS col ON itab.object_id = col.object_id JOIN sys.types AS typ ON typ.user_type_id Read More...
TSQL to check whether the table has a column with the specified name?
19 September 07 03:51 PM | SQL Master | 2 Comments   
Within SQL Server 2005: if Exists( select * from sys.columns where Name = N '<ColumnName>' and Object_ID = Object_ID ( N '<TableName>' ) ) begin --write your own code print relevant code columns for existence end else begin --write your own Read More...