Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2006
    Location
    DC
    Posts
    123

    Unanswered: Error with dynamic query

    still yet to figure out why i get this error with this query...
    Msg 241, Level 16, State 1, Line 11
    Conversion failed when converting datetime from character string.

    Know what the error is but all along the package queries etc... its a datetime datatype


    DECLARE @DatabaseName varchar(100)
    DECLARE @AuthenticationAuditTblTemp varchar(100)
    DECLARE @LastRunDate datetime
    DECLARE @LastRunDateDest datetime
    SET @LastRunDate = getdate()
    SET @LastRunDateDest = getdate()
    SET @AuthenticationAuditTblTemp = 'testing2'
    SET @DatabaseName = 'testing'
    DECLARE @SQLINSERT varchar(3000)
    --Insert Data into Temp Table
    SET @SQLINSERT = 'Insert Into ' + @DatabaseName + @AuthenticationAuditTblTemp + '
    (Id,
    CreatedDateTime,
    UserNameAttempted,
    RemoteAddress,
    Success,
    MtmUserId)
    SELECT
    Id,
    CreatedDateTime,
    UserNameAttempted,
    RemoteAddress,
    Success,
    MtmUserId
    FROM ' + @DatabaseName + '.dbo.AuthenticationAudit
    WHERE ' + @LastRunDate + ' < ' + @LastRunDateDest + ''
    print @SQLINSERT

    any suggestions on what I'm missing

  2. #2
    Join Date
    Jun 2006
    Location
    DC
    Posts
    123
    figured it out...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •