Replace text in a TEXT type data column
SELECT REPLACE(SUBSTRING(Note, 1, DATALENGTH(Note)), CHAR(13), '
') AS Expr1 FROM OLD_NOTES
TextSnippets > codeguy > tsql
2359 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
Sean Harvell sean.harvell.ws
SELECT REPLACE(SUBSTRING(Note, 1, DATALENGTH(Note)), CHAR(13), '
') AS Expr1 FROM OLD_NOTES
--If all arguments are NULL, COALESCE returns NULL. COALESCE(expression1,...n) --is equivalent to this CASE function: CASE WHEN (expression1 IS NOT NULL) THEN expression1 --... WHEN (expressionN IS NOT NULL) THEN expressionN ELSE NULL
declare @email nvarchar(255) declare CustList cursor for SELECT email from STE_EMAILS OPEN CustList FETCH NEXT FROM CustList INTO @email WHILE @@FETCH_STATUS = 0 BEGIN if (SELECT count(custid) from leads where (current_customer=1) and (notes1 is not null) and (notes1 like '%' + @email + '%')) > 0 SELECT custid from leads where (current_customer=1) and (notes1 is not null) and (notes1 like '%' + @email + '%') print '%' + @email + '%' FETCH NEXT FROM CustList INTO @email END CLOSE CustList DEALLOCATE CustList