Discussion Locked

Checking for Empty Tables in SQL

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I want to import a table, but before I connect and import i would like to check if the table is populated with data. Any help on proper SQL queries.

3 replies

by medievaldude

How about this:
DECLARE @NumRows INT
SELECT @NumRows = COUNT(*) FROM mytable
IF @NumRows > 0
BEGIN
...
END

This discussion is closed to new replies.