Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Need help to find a script.

Author  Topic 

NguyenL71
Posting Yak Master

228 Posts

Posted - 2010-07-15 : 16:17:04
Hi all,

I am looking for the script which return column name either has NULL or 1900-01-01.
Ex: Insertdt and Typecd should be return. I need to be able to find all the tables.
SQL 2008.

Any help would greatly appreciate.

IF OBJECT_ID('TestTable', 'u') IS NOT NULL
DROP TABLE TestTable
GO
CREATE TABLE TestTable
(
LCPI INT NULL,
Insertdt DATETIME NULL,
TypeCd CHAR(5) NULL
)
GO

INSERT INTO TestTable VALUES(123079,NULL, NULL)
INSERT INTO TestTable VALUES(123098,'1900-01-01', NULL)
GO

SELECT *
FROM TestTable;
GO

-- Desired results:
TableName ColName
--------- -------
TestTable Insertdt
TestTable TypeCd

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-07-15 : 16:19:30
http://vyaskn.tripod.com/search_all_columns_in_all_tables.htm

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -