Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
If my query does not find a match in the table, such that there is not data to feed to a subsequent step, then there will be an error. Is it possible to detect the condition when no matches have been found after the completion of the query, I can detect this and can force some output. Thanks.Gerry
gshacte
Starting Member
17 Posts
Posted - 2010-03-18 : 23:00:32
That topic title I made was miserable. I should have written it as 'How to detect when a query is complete and there is no match'.Gerry
haroon2k9
Constraint Violating Yak Guru
328 Posts
Posted - 2010-03-19 : 01:04:14
quote:Originally posted by gshacte That topic title I made was miserable. I should have written it as 'How to detect when a query is complete and there is no match'.Gerry
Could you please show us some data with expected output.
gshacte
Starting Member
17 Posts
Posted - 2010-03-19 : 06:54:50
Yes. Following is one row of output. 2010-03-16 00:00:00.000 12:30:00 2010-03-16 00:00:00.000 14:00:00 2010-03-16 12:30:00.000 2010-03-16 14:00:00.000 1206 0013 63152 2010-03-16 07:00:00.000 2010-03-16 14:00:00.000 FRANCISCO J. RODRIGUEZGerry
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts
Posted - 2010-03-19 : 07:24:57
Follow the link in my signature on "How to ASK". It will show you how to provide sample data and output.http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp
Lumbago
Norsk Yak Master
3271 Posts
Posted - 2010-03-19 : 08:50:28
What you could do is something like this:
SELECT Col1, Col2, Col3 FROM table WHERE SomeCriteria = '...*UNION ALLSELECT '', '', '' --> Data types in this line must correspond with the datatypes in the "real" select
And then in your front end just remove the last line if your rowcount() > 1- LumbagoIf the facts don't fit the theory, change the facts. Albert Einstein