Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

\ (Backslash) (Transact-SQL)

Applies To: SQL Server 2014, SQL Server 2016 Preview

Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).

Breaks a long string constant into two or more lines for readability.

Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database.

Topic link icon Transact-SQL Syntax Conventions

<first section of string> \
<continued section of string>

<first section of string>

Is the start of a string.

<continued section of string>

Is the continuation of a string.

This command returns the first and continued sections of the string as one string, without the backslash.

The backslash is not a Transact-SQL statement. It is a command that is recognized by the sqlcmd and osql utilities and SQL Server Management Studio Code Editor.

The following example uses a backslash and a carriage return to split the string into two lines.

SELECT 'abc\
def' AS ColumnResult;

Here is the result set.

ColumnResult

------------

abcdef

Community Additions

ADD
Show:
© 2015 Microsoft