Reputation: 2082
I am using the "generate scripts" feature in SQL Server Management Studio.
When my scripts are generated the datetime values appear in hex. Is there any way to make them appear in plain text?
Thank you.
Edit 1: Example: INSERT [dbo].[CnfgTableOption] ([tableoptionkey], [tablekey], [optiondesc], [optiondescshort], [sortorder], [activeind], [createddate], [createdby], [modifiedby], [modifieddate], [optionaldesc1], [optionaldesc2], [label], [code1], [optnumericvalue]) VALUES (649, 128, N'MA', N'MA', 1, 1, CAST(0x00009EC800EB51F8 AS DateTime), 1, 1, CAST(0x00009EC800EB51F8 AS DateTime), NULL, NULL, NULL, NULL, NULL)
CAST(0x00009EC800EB51F8 AS DateTime)
Upvotes: 3
Views: 479
Reputation: 11406
From the looks of it, no.
There are 31 advanced options within the script wizard but none of them specify how dates should appear in the script.
When I ran a profiler trace against the action of scripting a database with a single table, the SQL statement to cast the date as binary was visible as a SQL:BatchCompleted event:
SELECT [id], CAST([date_value]) AS BINARY(8)) AS [date_value]
FROM [dbo].[example]
I would ask the question, does it matter that it's cast as a binary? The data will be read correctly from the script.
Example:
DECLARE
@d DATETIME,
@b BINARY(8)
SET @d = '2012-05-25 23:59:59.123'
SELECT @b = CAST(@d AS BINARY(8))
SELECT CAST(@b AS DATETIME)
-----------------------
2012-05-25 23:59:59.123
Upvotes: 1