社区
MS-SQL Server
帖子详情
有关select @var 在exec () 中 的模梭两可的问题,急
tofool
2003-05-20 09:55:15
declare @code int
select @code=-1
select @sql='select @code=code from '+@tablename+' where '+ ltrim(rtrim(@field))+' is null '
print @sql
exec(@sql)
注:所有的变量都有定义。
它提示的错误信息是:必须定义@code 。
我想有什么办法 达到 我想要的结果??! 换一个方法也行!
...全文
132
7
打赏
收藏
有关select @var 在exec () 中 的模梭两可的问题,急
declare @code int select @code=-1 select @sql='select @code=code from '+@tablename+' where '+ ltrim(rtrim(@field))+' is null ' print @sql exec(@sql) 注:所有的变量都有定义。 它提示的错误信息是:必须定义@code 。 我想有什么办法 达到 我想要的结果??! 换一个方法也行!
复制链接
扫一扫
分享
举报
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
tofool
2003-05-20
打赏
举报
回复
请问,sp_executesql 是不是任何角色,都可以使用??
还是只有admin 角色才能使用!?
happydreamer
2003-05-20
打赏
举报
回复
要用sp_executesql exec不支持动态输出
愉快的登山者
2003-05-20
打赏
举报
回复
declare @code int
select @code=-1
select @sql=N'select @code=code from '+@tablename+' where '+ ltrim(rtrim(@field))+' is null '
execute sp_executesql
@sql,
N'@code int output',
@code = @code output
select @code
pengdali
2003-05-20
打赏
举报
回复
declare @code int,@sql nvarchar(4000)
select @code=-1
select @sql='select @code=code from '+@tablename+' where '+ ltrim(rtrim(@field))+' is null '
print @sql
exec sp_executesql @sql,N'@code int output',@code output
select @code
pengdali
2003-05-20
打赏
举报
回复
declare @code int,@sql nvarchar(4000)
select @code=-1
select @sql='select @code=code from '+@tablename+' where '+ ltrim(rtrim(@field))+' is null '
print @sql
exec sp_executesql @sql,N'@code int output',@code output
select @code
firetoucher
2003-05-20
打赏
举报
回复
select @sql='
declare @code int
select @code=-1
select @code=code from '+@tablename+' where '+ ltrim(rtrim(@field))+' is null '
print @sql
exec(@sql)
pengdali
2003-05-20
打赏
举报
回复
declare @code int
select @code=-1
select @sql='select @code=code from '+@tablename+' where '+ ltrim(rtrim(@field))+' is null '
print @sql
exec sp_executesql @sql,N'@code int output',@code output
select @code
动态
SELECT
TOP @
var
在SQL Server
中
本文介绍在SQLServer
中
动态设置查询返回行数的方法,包括SQL2005+和SQL2000的不同实现方式,以及使用动态SQL和
exec
命令的技巧。
SQLModel 读取数据指南:用
select
() 与 session.
exec
() 查询全部 Hero 记录
本文详解SQLModel
中
使用
select
()构建查询语句与session.
exec
()执行全量读取Hero记录的完整流程,涵盖建表、写入、查询三阶段13个关键步骤;深入剖析SQLModel对SQLAlchemy
Select
和Session的封装机制,包括类型安全推导、自动scalars()调用及编辑器友好设计,并对比原生SQL与Python ORM查询差异。
SQLModel 读取数据实战:从 SQL
SELECT
到
select
(Hero) 与 session.
exec
的完整指南
本文详解SQLModel读取数据库数据的完整流程:基于Hero模型,通过创建Session、使用
select
(Hero)构造查询语句、调用session.
exec
执行并遍历结果,支持直接获取Hero对象列表(results.all())及一行式紧凑写法。重点解析SQLModel对SQLAlchemy
select
和
exec
方法的增强设计,包括类型注解重载、自动scalars()调用等关键技术细节,强调engine共享与session隔离的设计理念。
PDO 的
exec
() 方法和
exec
ute()的区别到底是什么?
本文详细介绍了PDO的
exec
()和
exec
ute()方法的区别。
exec
()直接执行SQL,不支持参数绑定,返回受影响行数,适用于简单更新或删除;
exec
ute()执行预处理语句,支持绑定参数防注入,返回布尔值,用于需动态绑定参数的操作。还阐述了二者底层原理、程序流、数据流等内容。
SQLSERVER
中
exec
与
exec
sp_
exec
utesql 的用法及比较
文章详细对比了SQLSERVER
中
的
exec
和sp_
exec
utesql
两
种执行动态SQL的方法。
exec
适用于执行存储过程,但不支持动态SQL的输入和输出参数,可能存在SQL注入风险。sp_
exec
utesql则支持参数化查询,能重用执行计划,提高性能并降低SQL注入风险。文章强调了sp_
exec
utesql在动态SQL执行
中
的优势和安全性。
MS-SQL Server
34,876
社区成员
254,635
社区内容
发帖
与我相关
我的任务
MS-SQL Server
MS-SQL Server相关内容讨论专区
复制链接
扫一扫
分享
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章