So I've got a field, and I need to extract all characters to the right of the group of characters -1\.
I created a right function but it gives me some random result where -1\ is in the middle of the result.
So I think I screwed something up.
Any help?
Thanks so much!
EggHeadCafe - Software Developer Portal of Choice
BizTalk Application that inserts records into SQL from *.CSV File
http://www.eggheadcafe.com/tutorials/aspnet/6a535c9b-a5ee-46c8-9836-5dd6aefc6571/biztalk-application-that.aspx
So I've got a field, and I need to extract all characters to the right of the group of characters -1\.
I created a right function but it gives me some random result where -1\ is in the middle of the result.
So I think I screwed something up.
Any help?
Thanks so much!
EggHeadCafe - Software Developer Portal of Choice
Extending a TextBox Control in ASP.NET
http://www.eggheadcafe.com/tutorials/aspnet/abfc302a-e9b7-4b43-8919-d47cfb4b6482/extending-a-textbox-contr.aspx
1. Query that has the problem
2. some sample data to work it on
3. SQL Server version
Many Thanks
Simon
<Meredith Hitchcock> wrote in message
news:20091119112152me...@gmail.com...
CREATE TABLE Foo (
keycol INT PRIMARY KEY,
datacol VARCHAR(20));
INSERT INTO Foo VALUES(1, 'abc-1\def');
INSERT INTO Foo VALUES(2, 'abcdef');
INSERT INTO Foo VALUES(3, 'abc-1\');
INSERT INTO Foo VALUES(4, 'abc-1\d');
SELECT keycol, datacol,
CASE WHEN CHARINDEX('-1\', datacol) > 0
THEN STUFF(datacol, 1, CHARINDEX('-1\', datacol) + 2, '')
END AS right_side
FROM Foo;
/*
keycol datacol right_side
----------- -------------------- -----------
1 abc-1\def def
2 abcdef NULL
3 abc-1\
4 abc-1\d d
*/
DROP TABLE Foo;
--
Plamen Ratchev
http://www.SQLStudio.com
I am not exactly sure what you mean,
can you provide a sample ?
Did you look to the CHARINDEX function ?
Regards
Frank Uray
"Meredith Hitchcock" wrote:
> .
>