SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 use results from view in a where statement
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Constraint Violating Yak Guru

325 Posts

Posted - 09/13/2013 :  16:48:56  Show Profile  Reply with Quote
I have a sql server 2008 stored procedure where I want to use the results of a view in a where statement. I want to check to see if the results from the view is not null.

The sql looks like the following currently:

select top 5 from cust_table
where view value is not null.

Would you show me the t-sql that I would need to use to see if the results from the view is null?

Almighty SQL Goddess

38119 Posts

Posted - 09/13/2013 :  17:12:12  Show Profile  Visit tkizer's Homepage  Reply with Quote
You would join cust_table to the view and then specify your view condition.

select top 5 from cust_table c
join viewname v
on c.somecolumn=v.somecolumn
where view.somepossibleothercolumn is not null

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server

Subscribe to my blog
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000