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

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.