Passing Parameters in URL Queries
 
In the article titled Configuring Web Queries In SQL Server, we saw how to configure SQL Server to accept URL queries. We also saw how to execute a simple URL query. Apart from allowing simple SQL queries, a URL query can also accept parameters. These parameters are appended to the URL query and will be replaced when executed. Here is a simple example:

http://localhost/pubs?sql=SELECT * FROM authors WHERE au_id = ? FOR XML AUTO&root=Custom&au_id=213-46-8915

Note that in the query above, we specified au_id = ?. This means that the value for the au_id parameter will be picked from the URL. This parameter is specified at the end of URL as &au_id=213-46-8915. The output of this query will be the record that corresponds to the author ID specified.

Related Articles:

Calling Stored Procedures through URL queries

Home