0

Possible Duplicate:
INFORMATION_SCHEMA vs sysobjects

I'm maintaining an old system (SQL Server 2005) and have come across 2 versions of a select statement that do the same thing.

Is one of the statements below more valid than the other?

SELECT 1 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_NAME = 'tblMyTable' AND COLUMN_NAME = 'MyColumn'

or

SELECT 1  
FROM sys.columns 
WHERE object_id = OBJECT_ID(N'[dbo].[tblMyTable]') AND name = N'MyColumn'
Community
  • 1
  • 1
TeamWild
  • 2,460
  • 8
  • 43
  • 53
  • http://stackoverflow.com/questions/3653637/sql-server-should-i-use-information-schema-tables-over-sys-tables – hgulyan Aug 30 '12 at 10:35
  • 4
    `INFORMATION_SCHEMA` is the ANSI-compliant version - this *should* work on any RDBMS that claims to support the ANSI/ISO SQL standard. `sys.columns` is the SQL Server specific version which is more flexible, more powerful - but product-specific – marc_s Aug 30 '12 at 10:36
  • Cheers guys. @marc_s, that's a great answer. – TeamWild Aug 30 '12 at 10:57

0 Answers0