Browse by Tags

Different ways to know structure of a table
Published 28 February 8 2:51 AM | SSQA.net
You can use one of the following to know the structure of a table 1 Generate SQL Script option from Enterprise Manager/Management Studio 2 select * from information_schema.columns where table_name='table_name' 3 EXEC sp_help 'table_name'...
SQL Server SP_HELPINDEX - updated version that includes column names
Published 3 January 8 1:46 PM | SSQA.net
Here is the incentive for the SQL Server users (this new year), you may be aware then using SP_HELPINDEX or SP_HELP could give some part of information on the indexes and database objects. But to know more about depedant columns you need to query INFORMATION_SCHEMA...
Replication FAQ series - Which columns are published in snapshot or transactional or merge publications in this database?
Published 11 December 7 6:48 PM | SSQA.net
Here is script you can find which columns are published in the replication that is using either snapshot or transactional or merge publications. --For snapshot or transactional publications select object_name(object_id) as tran_published_table, name as...
TSQL to check whether the table has a column with the specified name?
Published 19 September 7 5:51 PM | SSQA.net
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...
Getting table name from column name
Published 15 September 7 7:23 AM | SSQA.net
If you know the name of one column you want to find from which table that is originated, to retrieve the table name you can use following TSQL: SELECT CASE (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS AS c2 WHERE c2.TABLE_NAME = c1.TABLE_NAME AND...
TSQL to find computed column expression columns
Published 27 July 7 2:34 AM | SSQA.net
USE <dbname>; GO SELECT OBJECT_NAME(d.referenced_major_id) AS referenced_name ,COL_NAME(d.referenced_major_id, d.referenced_minor_id) AS referenced_columns ,OBJECT_NAME(referenced_major_id) AS dependent_object_name ,COL_NAME(d.object_id, d.column_id...
How do I find all the statistics and statistics columns on a specified object?
Published 16 July 7 7:46 AM | SSQA.net
USE <database_name>; GO SELECT s.name AS statistics_name ,c.name AS column_name ,sc.stats_column_id FROM sys.stats AS s INNER JOIN sys.stats_columns AS sc ON s.object_id = sc.object_id AND s.stats_id = sc.stats_id INNER JOIN sys.columns AS c ON...