Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

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

Constraint Violating Yak Guru

332 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

38200 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  
 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.02 seconds. Powered By: Snitz Forums 2000