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.

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



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

From INVENTJOURNALTRANS v with (nolock)
Where v.TRANSDATE between @FromDatetime and @ToDatetime
and v.BOMLINE=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.

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.

commented: learn something new every day, thanks. +4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.