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 |
jszulc
Yak Posting Veteran
66 Posts |
Posted - 2012-03-02 : 08:00:05
|
How can I build a query to show all records from vm_sites with site column populated based on matches from Assets table? The number of records in vm_Sites should be still the same after the match, just trying to match all nulls in vm_Sites with Assets table.Table 1SELECT Sname,site,volsize from vm_SitesTable 2SELECT Sname,site from AssetsThank you |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-02 : 12:33:00
|
you cant match NULLs as NULL cant be equated to NULL under default conditions. NULL means its unknown value and its not a value by itself. So comparison between two NULL doesnt even make senseif for matching actual values you can use below logicSELECT *FROM vm_sites vWHERE EXISTS (SELECT 1 FROM Assests WHERE site = v.site and if you really think all NULL in your case have to be treated equivalent use ISNULL or COALESCE functions to change them to valid default value before comparison------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|