关于SQL中exec sp_executesql的解释
exec sp_executesql N'SELECT LA001, LA014, LA005, LA011, LA013, LA021 FROM cgjterp..INVLA INVLA
WHERE LA001=@P1 AND LA009=@P2
ORDER BY LA001, LA009
', N'@P1 varchar(20),@P2 varchar(10)', '301110101001', '01'
这是执行动态sql的
exec sp_executesql N'SELECT LA001, LA014, LA005, LA011, LA013, LA021 FROM cgjterp..INVLA INVLA
WHERE LA001=@P1 AND LA009=@P2
ORDER BY LA001, LA009
' 到这里是定义一个动态sql
N'@P1 varchar(20),@P2 varchar(10)' 是对动态sql里用的变量申明
'301110101001', '01' 给相应的变量赋值