sql server user defined function - parse a string

sql server user defined function - parse a string

Post by ppank » Wed, 22 Jan 2003 22:39:12



I am new to sql user defined functions. I need to write
one, that takes a delimited string (comma, or perhaps semi-
colon) and parses it out.

Are any code snippets available?

The intent is too use the parsing function to create
arguments for a sql SELECT clause and WHERE clause, to
pass to a stored procedure, to query a table.

 
 
 

sql server user defined function - parse a string

Post by John Kan » Thu, 23 Jan 2003 02:41:45


PPanke,
Could you be more specific? There are several UDF's as well as stored
procedures that can do what I *think* you're looking for.
Could you proved an example of what the input string would look like as well
as the select and where clauses?
Regards,
John


Quote:> I am new to sql user defined functions. I need to write
> one, that takes a delimited string (comma, or perhaps semi-
> colon) and parses it out.

> Are any code snippets available?

> The intent is too use the parsing function to create
> arguments for a sql SELECT clause and WHERE clause, to
> pass to a stored procedure, to query a table.


 
 
 

sql server user defined function - parse a string

Post by perry pank » Thu, 23 Jan 2003 03:00:08


I intend to provide the user, via a .net web page, a datagrid. It will
display, for a given table, a list of field names, a checkbox for each
field name, a text box for each field into which the user can enter a
sql filter string, and finally  a text box for each field into which the
user can enter an integer, to specify sort order.

This is a page which allows the user to filter what he wants to see in a
given table.

I want to pass a comma-delimited string to a stored procedure,
containing the user-selected field names. I will parse these out, to
complete a sql SELECT statement.

Similarly, I want to pass comma-delimited strings for the reamining user
inputs, to parse out the WHERE and GROUP BY portions of the sql
statement.

The resulting sql statement will get passed to a stored procedure, which
will execute it, and display the query results in a datagrid on a web
page.

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!