SQL Server: Using Parameters and Local Variables

I was trying to get a stored procedure in SQL Server to run using a mixture of parameters passed from an ASP.NET page and a local variable which I wanted to declare in order to modify one of the parameters received.

I couldn’t figure out where to put the local variable in relation to the parameters, until I found this page:

http://www.sqlteam.com/article/introduction-to-dynamic-sql-part-2

The parameters go before the ‘AS’ statement, the local variable after, but before the ‘BEGIN’ statement if you use it.