I have the following Case expression:
SELECT
CASE
WHEN item = '662627-4'
THEN 'KLX Licensed & BOM CONTAINS KLX LICENSED PART(S)'
ELSE NULL
The result is as follows:
KLX Licensed & BOM CONTAINS KLX LICENSED PART(S)
I would like to have it display like this on two lines:
KLX Licensed &
BOM CONTAINS KLX LICENSED PART(S)`
Is this possible? Is there a character to insert a carriage return in the case statement?
I'm using SQL Server 2016.
If you are using SSMS: You will not see a difference in the results grid, but you will if you set results to text (shortcut: Ctrl+T).
SELECT CASE WHEN item = '662627-4' THEN 'KLX Licensed & '+char(10)+'BOM CONTAINS KLX LICENSED PART(S)'
ELSE NULL end
or
SELECT CASE WHEN item = '662627-4' THEN 'KLX Licensed &
BOM CONTAINS KLX LICENSED PART(S)'
ELSE NULL end
rextester demo: http://rextester.com/YWD92075
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With