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 2012 Forums
 Transact-SQL (2012)
 parsing math string

Author  Topic 

noamg
Posting Yak Master

215 Posts

Posted - 2013-06-10 : 15:17:19
A store procedure get an input string,
like: ‘( TA or ( TB OR TC ) and ( TB AND TD ) )'

each number represents a table with list of UserIDs.
How to parse correctly string like this ?


Noam Graizer

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-06-10 : 17:37:30
quote:
Originally posted by noamg

A store procedure get an input string,
like: ‘( TA or ( TB OR TC ) and ( TB AND TD ) )'

each number represents a table with list of UserIDs.
How to parse correctly string like this ?


Noam Graizer

What do you want to get as the output if it is successfully parsed?

My initial reaction without knowing very much about it is that you will need to use some type of dynamic queries. However, if TA, TB etc. represent names of tables, that may not be possible.

In any case, using dynamic SQL by inserting strings passed in from a client is very unsafe and subject to SQL injection. So if at all you end up going that route, watchout for that, use parameterized queries etc.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-11 : 01:37:07
I'm getting confused reading the title and then explanation

Title says parsing math string
and explanation says
each number represents a table with list of UserIDs

can you clearly state the requirements with an example? is the attempt to merge data between tables which can be determined only at runtime?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-06-11 : 01:44:12
Duplicate Thread : http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=185960

@noamg, Do not open new threads for same problem

--
Chandu
Go to Top of Page
   

- Advertisement -