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 |
|
Goalie35
Yak Posting Veteran
81 Posts |
Posted - 2009-06-22 : 00:51:18
|
| I have a query that returns a bunch of user info but when you have a user who hasn't entered any data yet, the query obviouly returns no results.I need to setup a query so that if the query returns no results, I then simply return the top record in the database.Any idea how I can set this up?Thanks. |
|
|
doran_doran
Posting Yak Master
179 Posts |
Posted - 2009-06-22 : 01:03:51
|
| if exists (select * from someTable where field = something) - do somethingelse select top 10 from sometableend |
 |
|
|
Goalie35
Yak Posting Veteran
81 Posts |
Posted - 2009-06-22 : 01:13:36
|
| Thanks doran_doran, that did it! |
 |
|
|
doran_doran
Posting Yak Master
179 Posts |
Posted - 2009-06-22 : 01:55:23
|
| I am glad I could help. Good luck with your project. |
 |
|
|
|
|
|