Reputation: 41
I need to build query in SQL to get rows the have text like that 'TEXT1\r\nTEXT2'
.
For example something like that:
SELECT *
from Table1
where Name LIKE '%TEXT1\r\nTEXT2%'
Upvotes: 3
Views: 227
Reputation: 116458
You can put the characters in with the CHAR
function:
SELECT *
FROM Table1
WHERE Name LIKE '%TEXT1' + CHAR(13) + CHAR(10) + 'TEXT2%'
In some RDBMSs you may also be able to put a literal newline in the constant (although it looks like SQL Server ignores this, at least on SQL Fiddle:
SELECT *
FROM Table1
WHERE Name LIKE '%TEXT1
TEXT2%'
Upvotes: 2
Reputation: 4647
SELECT * FROM Table1 WHERE Name LIKE '%TEXT1' + CHAR(13) + CHAR(10) + 'TEXT2%';
http://msdn.microsoft.com/en-us/library/ms187323.aspx
Upvotes: 4