Is the following c# snippet susceptible to a SQL Injection Attack?
string sql = @"
declare @sql navarchar(200)
set @sql = 'select * from customers where customerId = ' + convert(navarchar, @custId)
exec sp_sqlexec @sql
"
oSQL.Parameters.Add("custId", CustomerId);
DataTable dt = oSQL.ExecuteDataTable(sql);
I understand this is a trivial sql statement but I'm more interested in the approach of using exec sp_sqlexec
. The sql statement is more dynamic than the one stated but don't think it's important for my question.