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.
Author |
Topic |
davenims
Starting Member
21 Posts |
Posted - 2008-03-05 : 11:33:07
|
- I have a report based on a stored procedure (spRouteCard) containing instructions for making a job. The instructions are stored as templates which can contain "tags" such as <Length>, <LengthUnits> etc.- When the report is printed, each instruction is run through a UDF (fProcessTags) which replaces the tags with the actual values for that job.OK that's the part that works, but now I am also trying to allow adding calculations on the tags by putting basic math formulas inside curly brackets. So for example, the user could enter {<Length> + 10}By the time the curly brackets come to be processed, the tags have already been replaced, so only the actual calculation needs to be done, eg. {200 + 5}I thought I would be able to just pick out the bits in curly brackets and use EVAL() to do the calculation, but soon found out that SQL Server doesn't have such a function.I had figured the next best way to do it was create a parsing function which would use sp_executesql, passing the results into a temp table, then using a cursor to return the result.Unfortunately, I have just discovered that temporary tables cannot be accessed from inside a function.Can anyone recommend the best way to tackle this?Much obliged! |
|
davenims
Starting Member
21 Posts |
Posted - 2008-03-05 : 11:50:35
|
I think what I just put it a bit long-winded, so basically if I had a record that reads:Cut to {300 + 10}mmHow could I process it so that it reads:Cut to 310mm |
 |
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2008-03-07 : 02:01:45
|
You could potentially achieve this with all sorts of string manipulation, but you might want to think about passing the numbers through separately and just addingJack Vamvas--------------------Search IT jobs from multiple sources- http://www.ITjobfeed.com |
 |
|
mayoorsubbu
Yak Posting Veteran
95 Posts |
Posted - 2008-03-11 : 04:30:09
|
Davenims,Try, select replace(replace(<colname>, '{', ''), '}', '') from <tablename> |
 |
|
|
|
|
|
|