3

I need to generate insert script from SQL Server and when i am using SQL Server Script Generator it CAST datetime values from hex e.g.

CAST(xxxxxxxxxxxxx as dateTime)

How can i avoid this ? I want actual value in script

1

1 Answer 1

4

Unfortunatly this is not possible , SQL Server internally produce hex value as DateTime value.

This hex value is logically divided into two group one is Date & other is Time.

e.g. 0x00009CEF00A25634 - hex value.

Date part :- 0x00009CEF (decimal 40175)

Time part :- 00A25634 (decimal 10638900)

If you select this hex value like,

select CAST (0x00009CEF00A25634 as datetime)

it return, 2009-12-30 09:51:03.000

I hope this answer is helpful for you.

Thanks.

Sign up to request clarification or add additional context in comments.

2 Comments

So does that mean if i leave i as it is, it will insert the correct date into target table?
Yes, If you see that generated insert script then there is already CAST function . SQL Server just show hex value but it has already put hex value into CAST function so now you can use generated script for insertion which will insert real DateTime value. Let me know for further query . Thanks...!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.