1Tests for empty (NULL) values.
2Example: Returns users that haven’t given a contact number.
3SELECT * FROM users
4WHERE contact_number IS NULL;
1declare @col varchar(255), @cmd varchar(max)
2
3DECLARE getinfo cursor for
4SELECT c.name FROM sys.tables t JOIN sys.columns c ON t.Object_ID = c.Object_ID
5WHERE t.Name = 'ADDR_Address'
6
7OPEN getinfo
8
9FETCH NEXT FROM getinfo into @col
10
11WHILE @@FETCH_STATUS = 0
12BEGIN
13 SELECT @cmd = 'IF NOT EXISTS (SELECT top 1 * FROM ADDR_Address WHERE [' + @col + '] IS NOT NULL) BEGIN print ''' + @col + ''' end'
14 EXEC(@cmd)
15
16 FETCH NEXT FROM getinfo into @col
17END
18
19CLOSE getinfo
20DEALLOCATE getinfo