0

Guys,

Using this query, i got an error. any idea guys.
what method should i used for this report.
Im using text queries instead of SP.
thanks.

The variable name '@FromDate' has already been declared. Variable names must be unique within a query batch or stored procedure.

Fromdate:'2012/06/01'
FromTime:12:00AM

Todate:'2012/06/29'
Totime:12:00PM

DECLARE @fromDateTime as datetime, @toDateTime as datetime
SET @fromdatetime = dbo.getCombinedDateTime(@fromDate,@fromTime)
SET @todatetime = dbo.getCombinedDateTime(@toDate,@toTime)

Select
v.JOURNALID
,v.TRANSDATE
,v.ITEMID
,v.QTY
,v.COSTAMOUNT
,v.JOURNALTYPE
,v.BOMLINE
From INVENTJOURNALTRANS v with (nolock)
Where v.TRANSDATE between @FromDatetime and @ToDatetime
and v.JOURNALTYPE=3
and v.BOMLINE=0

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by BitBlt
0

Put GO between SET and SELECT, failing that put GO between DECLARE, SET, SET and SELECT.

The GO key word tells it that it is executing something that is in a different batch, you have to use it if you're creating schemas and tables in the same script so i guess it's worth a try . . .

let me know how it goes.

1

Actuall, @ChrisHunter, putting a GO in between the statements will separate batches so you'll just lose your variable declarations. Try it.

To the OP, you're not giving us a lot of information. What is the error you get? Which statement is erroring? Can we assume the dbo.getCombinedDateTime is a user-defined function? If so, what happens inside it? What are it's parameter datatypes? What is it's return type?

I have my suspicions that the problem is inside the UDF, but we really can't help without more to work with.

Edited by BitBlt

Votes + Comments
learn something new every day, thanks.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.