Syntax Error

  • Sql Server 2k Reporting Services.

    When I run this query in the DATA window it works fine. When I run it in the PREVIEW panel I get this error:

    An error has occurred during report processing.

    Cannot read the next data row for the dataset

    Syntax error converting the nvarchar value '01/01/2008' to a column of data type int.

    Here is the query:

    declare @startdate smalldatetime

    declare @enddate smalldatetime

    Set @startdate = '01/01/2008'

    set @enddate = '01/04/2008'

    SELECT AutoID, Email_ID, CustomerID, Email, Password, FName, LName, Company, BusinessType, New_BusinessType, Address, Address2, City, State, Zip,

    Country, Phone, Fax, showroom, cast(Regdate as int) as REGDATE , hear

    FROM tblPro_Registration

    WHERE (Regdate >= @startdate AND Regdate < @enddate + 1)

    I am new at this and would appreciate any help.

    Thankyou.

  • Why are you casting regdate as an int? You will be better off converting whatever is in regdate into some date format. Try CONVERT(DATETIME,regdate,101) AS REGDATE. That will set whatever is in regdate to the mm/dd/yyyy format.

    HTH

    [font="Comic Sans MS"]toolman[/font]
    [font="Arial Narrow"]Numbers 6:24-26[/font]

  • Thanks for your help. Your solution worked. In answer to your question I am new at this company and have inherited the work of many consultants and employees who took the easy/fast/short way to do things.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply