【发布时间】:2012-08-21 15:22:07
【问题描述】:
我有一个接受输入 @featuretype 的 sp。 @featuretype 将等于“mobile”、“login”或“index”,并将对应于 db 中的列。
在我的 sp 我有:
EXEC(
'select TOP 3 * from featuredtypes_v where'+' featuredtypes_v.'+@featuretype+'Page=1'+
' order by featuredtypes_v.priority desc'
)
但是,有人告诉我这会打开数据库进行 sql 注入。我的两个问题是,为什么会这样,为了避免这种情况,我还能如何编写这个查询?
【问题讨论】:
-
想象
@featuretype是;drop table featuredtypes_v; -- -
很好地处理了这个问题,而不仅仅是把它扫到地毯下!
标签: sql tsql stored-procedures