• SQLTestUser (9/9/2013)


    Convert(datetime, DATEDIFF(day, 0, GETDATE())) worked

    IF EXISTS(

    select 1 from Xlog where LogDATE >= cast(getDate() as date) -- should this be datetime if i have Sql server 2005?

    )

    then PRINT 'Record already exists.' ;

    results in an error as

    Msg 156, Level 15, State 1, Line 4

    Incorrect syntax near the keyword 'then'.

    Remove 'then' before PRINT, it will work

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/