Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

string manipulation in Mssql 2008

Posted on 2011-10-31
3
Medium Priority
?
342 Views
Last Modified: 2012-05-12
Hi ,

I have a parameter list:
like  -LGENG -OF2 ORIENTL "VP1" "PS_PO_NCAAT0000020899_2464788".

I would like to replace the string completely beginning from VP1.  I believe I begin with the Left function.  What other functions would I need for the substitute with my new phrase.

Thanks,
Nigluc
0
Comment
Question by:Lucia
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
mcp111 earned 2000 total points
ID: 37057330
declare @str varchar(2000)
set @str='-LGENG -OF2 ORIENTL "VP1" "PS_PO_NCAAT0000020899_2464788"'

select left(@str, charindex('V',@str)-1) -- will give the desired result
--charindex finds the position of 'V' and we take all characters to the left of V and omit the rest

I think that's what you want.
0
 

Author Comment

by:Lucia
ID: 37057442
I tried this :

SELECT STUFF(PARMLIST,(CHARINDEX('ORIENTL',PARMLIST)+LEN('ORIENTL')),254,'"VP1" "TESTLNS"') FROM PSPRCSPARMS WHERE PRCSINSTANCE = '234031'

I will substitute the vp1, and testlns with variables.

Thank you,
nigluc
0
 

Author Closing Comment

by:Lucia
ID: 37057450
Thanks,

I put my brain to work as it is on a deadline :-)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question