Skip to content

Latest commit

 

History

History
103 lines (80 loc) · 3.09 KB

File metadata and controls

103 lines (80 loc) · 3.09 KB
title Backslash (Line Continuation) (Transact-SQL)
description Backslash (Line Continuation) (Transact-SQL)
author rwestMSFT
ms.author randolphwest
ms.reviewer
ms.date 07/25/2019
ms.prod sql
ms.prod_service database-engine, sql-database
ms.technology t-sql
ms.topic reference
ms.custom
f1_keywords
\_TSQL
\
helpviewer_keywords
backwhack
backslash
escape character
hack character
\ (backslash)
backslant
bash
reverse slant
slosh
reversed virgule
line continuation character
reverse solidus
dev_langs
TSQL

Backslash (Line Continuation) (Transact-SQL)

[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance]

\ breaks a long string constant, character or binary, into two or more lines for readability.

Topic link icon Transact-SQL Syntax Conventions

Syntax

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

[!INCLUDEsql-server-tsql-previous-offline-documentation]

Arguments

<first section of string>
Is the start of a string.

<continued section of string>
Is the continuation of a string.

Remarks

This command returns the first and continued sections of the string as one string, without the backslash. The new line after the backslash must either be a line feed character (U+000A) or a combination of carriage return (U+000D) and line feed (U+000A) in that order.

Examples

A. Splitting a character string

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

SELECT 'abc\  
def' AS [ColumnResult];  

[!INCLUDEssResult]

ColumnResult  
------------  
abcdef

B. Splitting a binary string

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

SELECT 0xabc\
def AS [ColumnResult];  

[!INCLUDEssResult]

ColumnResult  
------------  
0xABCDEF

See Also

Data Types (Transact-SQL)
Built-in Functions (Transact-SQL)
Operators (Transact-SQL)
(Division) (Transact-SQL)
(Division Assignment) (Transact-SQL)
Compound Operators (Transact-SQL)