Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variables in query

Status
Not open for further replies.

geraldjr30b

Programmer
Aug 27, 2015
9
US
hi. i have something like

Declare @today2 date
Set @today2 = MSPRunDate


Declare @datadate2 date
Set @datadate2 = (Select max(DateId)
From tablename (nolock)
Where BusinessDay = 'Y'
and DateId = @today2)

Declare @EOM2 date
set @EOM2 =
(SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@datadate2)+1,0)))


declare @BUSdaysremCURR2 int
set @BUSdaysremCURR2 =
(select count(*)-1
from
tablename
where dateid between @datadate2 and @EOM2
and BusinessDay = 'Y')


select
column,
column,

@today2 = EERunDate, --this variable is to be determined by the EERunDate for each record
@BUSdaysremCURR2 , --want this to be determined by looking at a column value and calculated by subtracting 2 dates in each record.

EOM2 ,
column,
column,
column,
column,
column,
column,
[column],
Ownership2,
...

i want the variables to change depending on the row of the query results. Please help.

Thanks


 
You don't need variables for that.
You need columns.

Borislav Borissov
VFP9 SP2, SQL Server
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top