• If you want to store the date of vidhya sagar query into a variable you would run this code.

    DECLARE @DateInserted DATETIME

    SET @DateInserted = CONVERT(DATETIME, (SELECT TOP(1) SUBSTRING(mdate,1,20) FROM ##tmp))

    Thanks for all your help