What is the use of '\' and '$' in T-SQL?
As I found (in SQL Server books):
\ (Backslash) (Transact-SQL)
Splits a long string constant into two or more lines for readability.
and
SELECT Clause (Transact-SQL)...$IDENTITY | $ROWGUID$IDENTITY | $ROWGUID
AND$PARTITION (Transact-SQL)
Returns the number of the section into which the set of values โโof the partition columns will be displayed for any given section function.
use \ and $ in T-SQL specifically by SQL Server.
Now I have a query like this:
SELECT \ a, $ b, \11 c, $12 d; This has the correct result:
a | b | c | d -----+------+-------+------- 0.00 | 0.00 | 11.00 | 12.00 I think there is something that I cannot find about these characters.
Edit:
I found that if a number appears after currency characters , SQL Server will delete the specified character and save the value as a monetary data type:
And I think that SQL Server translates the single currency symbol, which is the last phrase in the part - these parts are between + and - - formulas up to 0.00 and only at the end of the part, for example -$ , ($) , (12 + $) , ($) + 12 , $ * (12 - $) or so on, not $ + 1 , 2 * $ - 1 . I also found that $ 2 matches $2 .
All of the above behavior is the same for \ , which means that SQL Server considers that \ is a currency symbol !!!
I thought to check the data type, and each, as you will notice, each returns money of the data type.
WITH CTE AS ( SELECT \ a, $ b, \11 c, $12 d ) SELECT SQL_VARIANT_PROPERTY(a,'baseType') a, SQL_VARIANT_PROPERTY(b,'baseType') b, SQL_VARIANT_PROPERTY(c,'baseType') c, SQL_VARIANT_PROPERTY(d,'baseType') d FROM CTE Results:
abcd ------------------------------ ------------------------------ ------------------------------ ------------------------------ money money money money