To run this one-liner, open SQL Server Management Studio and right click on the database you want to run it on, then choose Start PowerShell.
Modify the following command and run it in the PowerShell window you just opened. Note that it may be possible to write a simpler command than this, but this one is simple and it works.
dir | % { dir ($_.displayname + '\columns') } | ? { $_.datatype -match 'varchar' } | select parent, datatype, name | % { invoke-sqlcmd -suppressprovidercontextwarning ("select '" + $_.parent + "', '" + $_.name + "', count(*) from " + $_.parent + " where `"" + $_.name + "`" = ''") } | ? { $_[2] -ne 0 }
0 comments:
Post a Comment