Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Join statement
Message
 
 
To
16/03/2010 08:27:08
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Environment versions
SQL Server:
SQL Server 2005
Application:
Desktop
Miscellaneous
Thread ID:
01454733
Message ID:
01454761
Views:
39
You can use derived table
SELECT * FROM (
     select * from dbo.SystemMessage union all select * from dbo.ApplicationMessage 
  ) dt1 WHERE MessageID = @lnMessageID
>
>I'm performing the following stored procedure to essentially join 2 tables, with identical structures, to amalgamate the list of system/application messages into one dataset:
>
>as
>begin
>set nocount on;
>select * from dbo.SystemMessage union all select * from dbo.ApplicationMessage order by MessageID
>end
>
>I now want to pass a parameter into this stored procedure, @lnMessageID, and I'd like the statement to perform the join and THEN return the record from the joined results that matches @lnMessageID. @lnMessageID is always unique.
>
>Regards
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform