Now I did a little testing with the BIGINT value to deteremine the maximum BIGINT value that could be converted to DATETIME as follows:
DECLARE @b-2 BIGINT
SET @b-2 = 2958457
WHILE @b-2 < = 2958464
BEGIN
SELECT convert(VARCHAR(20),CAST(@B AS DATETIME),101),@B
END
The last value BEFORE the error message was: 2958463
In your code if you will be attempting to convert a BIGINT value to a date use something like :
SELECT convert(VARCHAR(20),CAST(@B AS DATETIME),101) WHERE @b-2 < 2958463
In order to clarify or confuse here are the result of additional code.
DECLARE @b-2 BIGINT
SET @b-2 = 41046
SELECT @b-2 AS 'Bigint',CAST(@B AS BINARY(8)) AS 'Binary 8',convert(VARCHAR(20)
,CAST(@B AS DATETIME),101) AS 'Date'
SELECT CAST(GETDATE() AS BIGINT) AS 'Bigint'
,CAST(GETDATE() AS BINARY(8)) AS 'Binary 8',GETDATE() AS 'Date'
Result:
Bigint Binary 8 Date
41046 0x000000000000A056 05/19/2012
41046 0x0000A0560090F582 2012-05-19 08:47:46.780
To clarify read more:
http://www.sql-server-performance.com/2004/datetime-datatype/