| Author |
Topic |
|
Sql newbie1
Starting Member
8 Posts |
Posted - 2011-02-26 : 12:19:14
|
| Hi guysI have compiled a query usng declare as there are quite a few tables involved usng the same primary key. What I want to know is if there is a way to just display the tables that have results in them rather than what happens now which is that it shows all the tables in the results window with the ones that have no entries being blank? Any help would be appreciated. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-02-26 : 12:48:35
|
| you can use if condition achieve this. just check for condition count(*) > 0 from tables before displaying them------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Sql newbie1
Starting Member
8 Posts |
Posted - 2011-02-26 : 15:16:03
|
| Thanks for the reply, would you possibly be able to give me an example script? |
 |
|
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2011-02-26 : 15:21:48
|
| "A problem well stated is a problem half solved." -- Charles F. KetteringPlease post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. If you know how, follow ISO-11179 data element naming conventions and formatting rules. Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. Sample data is also a good idea, along with clear specifications. It is very hard to debug code when you do not let us see it. If you want to learn how to ask a question on a Newsgroup, look at: http://www.catb.org/~esr/faqs/smart-questions.html--CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
 |
|
|
Sql newbie1
Starting Member
8 Posts |
Posted - 2011-02-26 : 18:29:34
|
| thnx for the reply. All I want is to not display any tables in the results that have no entries instead of showing them with no results |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-03-03 : 09:41:55
|
| if exists(select * from table)select .........MadhivananFailing to plan is Planning to fail |
 |
|
|
Sql newbie1
Starting Member
8 Posts |
Posted - 2011-03-03 : 17:15:55
|
| Brilliant, thanks for the reply |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Sql newbie1
Starting Member
8 Posts |
Posted - 2011-03-04 : 03:21:52
|
| Sorry yes only display tables with result (data)s in them rather than all tables inc ones with no results |
 |
|
|
|