April 10, 2017 at 9:11 am
Select * from (
select
EM.col1,
ST.col2,
ST.col3
from vwEmployee EM
inner join vwStudent ST
on Em.ID = ST.ID
Union
select
EH.col1,
EH.col2,
ST.col3
from vwEmployeeHeader EH
inner join vwStudent ST
on Em.ID = ST.ID
) Results
I have to give the paramter for this whole query ; How can i modify this query to add EM.Date > ?
I have the package where it checks the count of records form this query based on paramter date; where to add this EM.Date > ? on the abouve query?
I know i can add on the first select query using where condition but i want this on the complete query
April 10, 2017 at 9:24 am
Considering that you are using a ? to define your parameter, can i assume that this in actually an SSIS SQL Execute task?
If so, you could do:WITH Employee AS (
select EM.col1,
ST.col2,
ST.col3,
EM.date
from vwEmployee EM
inner join vwStudent ST on Em.ID = ST.ID
Union
select EH.col1,
EH.col2,
ST.col3,
EH.Date
from vwEmployeeHeader EH
inner join vwStudent ST on Em.ID = ST.ID)
SELECT E.col1, E.Col2, E.Col3
FROM Employee E
WHERE E.Date > ?;
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
April 10, 2017 at 10:04 am
I am getting parse error -
Incorrect syntax near ')'.
and also the columns SELECT E.col1, E.Col2, E.Col3
FROM Employee E
WHERE E.Date > ?;
are showing invalid..
April 10, 2017 at 10:08 am
mcfarlandparkway - Monday, April 10, 2017 10:04 AMI am getting parse error -Incorrect syntax near ')'.
and also the columns SELECT E.col1, E.Col2, E.Col3
FROM Employee E
WHERE E.Date > ?;are showing invalid..
What is the full SQL you ran? I can't see any syntax errors in what I provided you.
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
April 10, 2017 at 11:22 am
Post the full T-SQL, please, including anything that may have run before it in the same window / task.
Also, are you running this in a SSIS package, an SSMS window or in some other program?
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply