Thursday, March 04, 2010

T-SQL InformationSchema.Columns

A handy bit of T-SQL was passed to me today (by @jaminadey) which returns all the fields in a given table which are non-null...
  • SELECT * FROM INFORMATION_SCHEMA.Columns where TABLE_NAME = '' and is_nullable = 'NO'
Of course, you'll see there are lots of other fields which can be inspected, so play around and introspect that DB!

No comments:

Post a Comment