The other reason is that your code will run faster, since SQL Server will be able to cache your query for the next time you call it.
Every query that you send to SQL Server (or any SQL-aware database) needs to be parsed to make sure it's valid SQL, and that the objects in the query (tables, columns, etc) exist in the database. By using parameters, the query that SQL Server sees is identical every time you call it, so it's able to find that query in it's procedure cache. Example:
[tt]
SELECT FirstName, LastName
FROM tbl_User
WHERE UserID = 232
SELECT FirstName, LastName
FROM tbl_User
WHERE UserID = 233
[/tt]
This results in both queries being parsed every time (and stored in the procedure cache) because they're not 100% identical. If you had coded it with parameters, the database would see this instead:
[tt]
SELECT FirstName, LastName
FROM tbl_User
WHERE UserID = ?
SELECT FirstName, LastName
FROM tbl_User
WHERE UserID = ?
[/tt]
The first one would have been parsed and stored in the cache before execution. The second one would have run much faster because SQL Server is able to pull it out from cache (skipping the expensive parse step entirely) before running it. Every time you run that query afterwards results in it being pulled from cache, with a huge overall performance increase.
Chip H.
If you want to get the best response to a question, please check out FAQ222-2244 first