Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling SQL Server Management Studio Scripts generation

Tags:

sql

sql-server

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)

like image 682
Para Avatar asked Dec 04 '25 16:12

Para


1 Answers

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
like image 96
8kb Avatar answered Dec 12 '25 00:12

8kb



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!