Alex Rivera | Logout

Check whether a table contains rows or not sql server 2005

Asked 2010-01-27T09:59:00.310
70

How to Check whether a table contains rows or not sql server 2005?

Edit
Report

1 Answer

114

For what purpose?

  • Quickest for an IF would be IF EXISTS (SELECT * FROM Table)...
  • For a result set, SELECT TOP 1 1 FROM Table returns either zero or one rows
  • For exactly one row with a count (0 or non-zero), SELECT COUNT(*) FROM Table
answered 2010-01-27T10:14:45.443

Your Answer