Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 split string in sql server

Author  Topic 

collie
Constraint Violating Yak Guru

400 Posts

Posted - 2009-03-29 : 16:52:09
Hi,

I am using an application that is sending parameter @returnvalue to a stored procedure. The parameter is in the format below.
I need to return the entire string before the first --- Original Message ---and nothing after that.

How can I do that?
Please note I don't have access to the actual code only to the stored procedure so it must be done in the stored procedure itself.

THanks

<html><head><style type="text/css">p {margin-bottom: 0; margin-top: 0;}</style></head><body>
<//BLK0000000000><font size="2"><div style="width:100%;word-wrap:break-word;font-family: Arial;color: #000000;">whisky</div></font><br />
<//BLK0000000000><br><br><div>--- Original Message ---<BR>From: "collie xxx" <collie@bs.com><BR>Received: 3/29/09 11:16:40 PM IDT<BR>To: "support"
<support@xx.com><BR>Subject: webmaster<BR><BR>
>--- Original Message ---<DIV></div>
</body></html>


Whisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much.

nshankar
Starting Member

9 Posts

Posted - 2009-03-30 : 01:37:12
Hey are u trying to send return value from the back end and display before the original message. then assign a label and assign the return value to that
Go to Top of Page

collie
Constraint Violating Yak Guru

400 Posts

Posted - 2009-03-30 : 03:10:53
Hi,

What do you mean by label? I can't add any controls to the application as i don't have access to the code. I only have access to the sp. That is why i need to split the string in the sp itself.



Whisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much.
Go to Top of Page

matty
Posting Yak Master

161 Posts

Posted - 2009-03-30 : 04:03:26
DECLARE @p VARCHAR(MAX)
SET @p=
'<html><head><style type="text/css">p {margin-bottom: 0; margin-top: 0;}</style></head><body>
<//BLK0000000000><font size="2"><div style="width:100%;word-wrap:break-word;font-family: Arial;color: #000000;">whisky</div></font><br />
<//BLK0000000000><br><br><div>--- Original Message ---<BR>From: "collie xxx" <collie@bs.com><BR>Received: 3/29/09 11:16:40 PM IDT<BR>To: "support"
<support@xx.com><BR>Subject: webmaster<BR><BR>
>--- Original Message ---<DIV></div>
</body></html>'

SELECT @p = SUBSTRING(@p,1,CHARINDEX('--- Original Message ---',@p)-1)
SELECT @p
Go to Top of Page

collie
Constraint Violating Yak Guru

400 Posts

Posted - 2009-03-30 : 04:48:47
Thanks, seems to be exactly what i need.
You are a life saver:-)


Whisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much.
Go to Top of Page
   

- Advertisement -