Wednesday, March 21, 2012
Interesting Query
I have four lookup tables that have identical structure. I have to
write a query to check if a particlaur string (code) exists in any of
the four lookups. What is the best way of dealing with this please?
1. Write one query with four corelated subqueries (one for each
lookup).
2. Write 4 separate queries and execute them one after the other.
If there is better way to store the lookups to make writing queries
like the one I have mentioned, easy, then I can change the lookup
tables.
ThanksIf all you have to test is existence, rather than return any value,
you could try something like:
SELECT CASE WHEN EXISTS(<query table 1> ) THEN 1
WHEN EXISTS(<query table 2> ) THEN 2
WHEN EXISTS(<query table 3> ) THEN 3
WHEN EXISTS(<query table 4> ) THEN 4
ELSE 0
END as Matched
Roy Harvey
Beacon Falls, CT
On 21 Apr 2006 03:43:14 -0700, "S Chapman" <s_chapman47@.hotmail.co.uk>
wrote:
>
>I have four lookup tables that have identical structure. I have to
>write a query to check if a particlaur string (code) exists in any of
>the four lookups. What is the best way of dealing with this please?
>1. Write one query with four corelated subqueries (one for each
>lookup).
>2. Write 4 separate queries and execute them one after the other.
>If there is better way to store the lookups to make writing queries
>like the one I have mentioned, easy, then I can change the lookup
>tables.
>Thanks|||Hi,
I'd rather create four left joins. Usually you need to return a value.
Tomasz B.
"Roy Harvey" wrote:
> If all you have to test is existence, rather than return any value,
> you could try something like:
> SELECT CASE WHEN EXISTS(<query table 1> ) THEN 1
> WHEN EXISTS(<query table 2> ) THEN 2
> WHEN EXISTS(<query table 3> ) THEN 3
> WHEN EXISTS(<query table 4> ) THEN 4
> ELSE 0
> END as Matched
> Roy Harvey
> Beacon Falls, CT
>
> On 21 Apr 2006 03:43:14 -0700, "S Chapman" <s_chapman47@.hotmail.co.uk>
> wrote:
>
>|||>> I have four lookup tables that have identical structure. I have to write
a query to check if a particular string (code) exists in any of the four loo
kups. What is the best way of dealing with this please? <<
The best way is not to split the encoding over four tables. Do you
also keep a personnel table for each employee's weight class?
This is a common design flaw called attribute splitting. You can build
a UNION-ed view and use it.
That view will also help show you that you have the same code with
different definitions in your data model (do you know the Patent Office
story?). Think you don't have this problem? Just wait. Or get the
extra overhead of prevetning it with triggers or other procedural,
proprietary code.
You will also have redundant data (look up a series of articles by Tom
Johnston on non-normal form redundancies).
Monday, March 12, 2012
Interactive sort doesn't work for multiple sub-reports
I have a report, which contains two nearly identical sub reports. In the IDE, when I test the containing report, each of the sub-reports works fine, in particular, the interactive sort feature works for both. When I deploy the reports to the test server (desktop running Windows XP, SQL Server 2005 Developer’s Edition, and SQL Reporting Services 2005, reports are served as web pages), the interactive sort feature seems to work only for one of the sub-reports. The other sub-report causes a postback, and refreshes, but does not return sorted. It appears as though whichever sub-report I attempt to sort first, sorts fine. When I attempt to sort the other sub-report, it does not sort.
Any ideas?
May not help, but when I have gotten these types of errors before, often deleting the primary and sub-reports from the Report Server and then redeploying all reports will help. I don't know why, but we have to do that often for deployment when there are certian types of changes.
Good luck.
|||Thanks for the reply! Unfortunately, this did not help. Anyone else run into problems with the built-in sorting for sub-reports?|||Hi Dan -
I was not able to reproduce your problem with mulitple subreports and user sort. Could you please go to http://connect.microsoft.com/ and file a defect report and attach your .rdl files.
Thanks, Jon
SQL Reporting Services Team
i have the same problem. A report with 3 sub-reports, on the third one the sort seem's to be disabled, i can see arrows but if i click on them only a postback occur without sorting and the two arrows stay (normally only one remain into a blank circle after a sort). If i run this sub-report alone, the sorting is working.
If i remove the third sub-report, the same problem happen on the second sub-report. The sorting was working before. Strange bug i think.
I have SQL Server 2005 SP1 with the latest fix after SP1 installed.
Sorry for my poor english... :)
Interactive sort doesn't work for multiple sub-reports
I have a report, which contains two nearly identical sub reports. In the IDE, when I test the containing report, each of the sub-reports works fine, in particular, the interactive sort feature works for both. When I deploy the reports to the test server (desktop running Windows XP, SQL Server 2005 Developer’s Edition, and SQL Reporting Services 2005, reports are served as web pages), the interactive sort feature seems to work only for one of the sub-reports. The other sub-report causes a postback, and refreshes, but does not return sorted. It appears as though whichever sub-report I attempt to sort first, sorts fine. When I attempt to sort the other sub-report, it does not sort.
Any ideas?
May not help, but when I have gotten these types of errors before, often deleting the primary and sub-reports from the Report Server and then redeploying all reports will help. I don't know why, but we have to do that often for deployment when there are certian types of changes.
Good luck.
|||Thanks for the reply! Unfortunately, this did not help. Anyone else run into problems with the built-in sorting for sub-reports?|||Hi Dan -
I was not able to reproduce your problem with mulitple subreports and user sort. Could you please go to http://connect.microsoft.com/ and file a defect report and attach your .rdl files.
Thanks, Jon
SQL Reporting Services Team
i have the same problem. A report with 3 sub-reports, on the third one the sort seem's to be disabled, i can see arrows but if i click on them only a postback occur without sorting and the two arrows stay (normally only one remain into a blank circle after a sort). If i run this sub-report alone, the sorting is working.
If i remove the third sub-report, the same problem happen on the second sub-report. The sorting was working before. Strange bug i think.
I have SQL Server 2005 SP1 with the latest fix after SP1 installed.
Sorry for my poor english... :)