DEV Community

Discussion on: Comparing SQL Views and Stored Procedures

Collapse
 
buinauskas profile image
Evaldas Buinauskas • Edited

A stored procedure is an encapsulation of logic that can be called from an application (or run in SQL Management Studio) to protect your database from SQL injection.

This is not true. A stored procedure could have a flaw and be vulnerable to SQL injection. That's very easy to do.

Collapse
 
rachelsoderberg profile image
Rachel Soderberg

I've updated the sections where I mentioned SQL Injection, as that is not something I am very familiar with. Thank you for the correction!

Collapse
 
udlose profile image
Dave Black

This is assuming that the stored procedure takes a VARCHAR or NVARCHAR parameter(s) AND uses these params to build a dynamic query. I think @JaredKarney meant that when you are using a stored procedure you are not building a dynamic sql statement. It's when you use dynamic sql statements that you are vulnerable to sql injection.