Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
yellowman
Starting Member
25 Posts |
Posted - 2012-12-03 : 09:20:20
|
I have the oddest problem when trying to look for empty/null values in a table. For some reason it doesn't pick them up as expected. The script is suppossed to return the database name if the schema version table is empty, but instead it doesn't return anything. Any ideas? SELECT @command = 'USE ' +@DB_Name+ ' SELECT '+ ''''+@DB_Name+ '''' +' as DB_Name, version_number FROM ' +@DB_Name + '.CQ_DBO.schema_version WHERE version_number = '' '' OR version_number IS NULL' EXEC sp_executesql @command |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-12-03 : 09:47:03
|
if you want to check table being empty, you should be using logic likeIF (SELECT COUNT(*)FROM DB.CQ_DBO.schema_version) = 0...------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
NeilG
Aged Yak Warrior
530 Posts |
Posted - 2012-12-03 : 09:49:39
|
Try looking at the below:http://msdn.microsoft.com/en-us/library/aa259229(v=SQL.80).aspx |
|
|
|
|
|