SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Manipulating string via multiple rows
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

strauss_jon
Starting Member

United Kingdom
23 Posts

Posted - 08/21/2014 :  11:33:02  Show Profile  Reply with Quote
Hi there

Just using set based SQL (not cursors or procs) is there a way to do the following.

I have a single string (which is a formula) tokenised with variables. I want to replace this string via variable / values pairs which corresponding to different components of the formula.

How can this be done via t-sql only. Essentially its looping through variable / value pairs and each time replacing the formula string, then the next iteration use the previously manipulated formula to de-tokenise it further until the whole formula has been replaced.

So simple example: formula is A+B

Variable Value Pair1: A = 8
Variable Value Pair2: B = 3

1st iteration: 8 + B
2nd iteration: 8 + 3

I tried using cross apply but that gives me multiple rows. Maybe for xml path - but i don't like using hacks.

Thanks in advance. Jon

  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000