I've come across the following t-sql:
SELECT {d'9999-12-31'}
Which returns 9999-12-31 00:00:00.000
.
This seems to be converting the type of the string literal to a DATETIME
. I can't find any documentation on this syntax and I'm wondering if there are any variations, for example if I have a literal 1
but want to represent this in a BIGINT
without using CONVERT()
/CAST()
.
Can anyone provide any further information on this syntax? Thanks.
These are ODBC escape sequences. See Date, Time, and Timestamp Escape Sequences for more details.
There is also similar syntax for uniqueidentifiers
SELECT {guid '00000000-0000-0000-0000-000000000000'}
,as well as procedure calls and some other constructs detailed off that link.
With regard to the rest of your question I'm not aware of any way of having an integer literal treated as a
bigint
or of any particular resource that lists all the ways of influencing how literals are assigned datatypes by SQL Server. Some ways are below.Returns