Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server Script Generator CAST datetime values from hex

Tags:

sql-server

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

like image 621
InTheWorldOfCodingApplications Avatar asked Sep 16 '26 02:09

InTheWorldOfCodingApplications


1 Answers

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.

like image 154
Anvesh Avatar answered Sep 18 '26 14:09

Anvesh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!