declare @sql varchar(8000)
declare @temp1 int
select @temp1 = 1set @sql='select top '+cast(@temp1 as varchar(10))+' * from xxx'exec(@sql)
解决方案 »
- sql 防注入语句怎么改,是否应该用replace语句, 在线等
- 哪位老兄帮忙看看sql2000写在作业里的语句
- 根据字段唯一查询
- 求tsql二表连接语句:互通有无
- 关于sql2005导出dbf文件问题
- 请问如何在SQL中比较时间
- 请问各位大侠,为什么VB.NET 2003不能运行VB.NET 2002的程序出错呢?
- [DBNETLIB][ConnectionWrite (send()).]一般性网络错误。请检查网络文档。
- 数据库原理高手:这个QBE语言的任务(域关系演算语言)怎么完成呢?
- 如何用ADO获取SQLServer服务器列表?急急。。。。。。。。。
- 有关sql 2000大型多媒体数据备份的问题,大家看看我的解决方案,或者给出好的建议!!
- 加密
select @temp1 = 1
exec('select top '+@temp1+' dateGuid from WorkingDay')
select @temp1 = 1
declare @s varchar(8000)
set @s='select top '+cast(@temp1 as varchar)+' dateGuid from WorkingDay '
exec(@s)
select @temp1 = 1
declare @s varchar(8000)
set @s='select top '+convert(nvarchar(10),@temp1)+' dateGuid from WorkingDay '
exec(@s)
declare @temp1 int
select @temp1 = 10
select top 1 @tempdate = CONVERT(datetime, wdate) from WorkingDay where dateGuid not in (select top ' + convert(nvarchar(50),@temp1) + ' dateGuid from WorkingDay where ORDER BY CONVERT(datetime, wdate) ) and isWorkingday = 1
上面的语句需要返回一个字,我用了 exec sp_executesql 方法,但在程序调用此函数有错误,不能这么用的
declare @temp1 int
select @temp1 = 10
select top 1 @tempdate = CONVERT(datetime, wdate) from WorkingDay where dateGuid not in (select top ' + convert(nvarchar(50),@temp1) + ' dateGuid from WorkingDay where ORDER BY CONVERT(datetime, wdate) ) and isWorkingday = 1
上面的语句需要返回一个@tempdate ,我用了 exec sp_executesql 方法,但在程序调用此函数有错误,不能这么用的
select @temp1 = 10
set @sql='select top 1 @tempdate = CONVERT(datetime, wdate) from WorkingDay where dateGuid not in (select top ' + convert(varchar(12),@temp1) + ' dateGuid from WorkingDay where ORDER BY CONVERT(datetime, wdate) ) and isWorkingday = 1 '
exec (@sql)