在存储过程中select i from A 定义个@j
如果@j不在查处来的i中
set @j=1咋写?这要在C#中我会,就是datatabel =select i from A where i!=j
if(datatable.rows.count<=0)
{
j=1
}但是在SQL存储过程中,如何找一个类似于datatable的变量来存取select i from A呢?怎么判断datatable.rows.count呢?注意: 是在存储过程中写
如果@j不在查处来的i中
set @j=1咋写?这要在C#中我会,就是datatabel =select i from A where i!=j
if(datatable.rows.count<=0)
{
j=1
}但是在SQL存储过程中,如何找一个类似于datatable的变量来存取select i from A呢?怎么判断datatable.rows.count呢?注意: 是在存储过程中写
解决方案 »
- [color=#FF0000]有关SqlServer2008的授权方式[/color]
- text类型字段修改
- 关于设置多个事务日志文件的问题
- 怎样修改表的文件组,急,急,急
- 有没有DELPHI的兄弟,去 http://www.91delphi.com 看看吧! 速度很快哦!!
- 直接返回结果集还是创建视图,全身分求救啊
- 面试题,数据库方面的,谢谢
- 求教:怎样将VFP中的表的字符型日期转换成DATE型
- 请问高人,如何用SERVER7的全局变量或系统存储过程获取一条SQL语句的执行时间?
- [!!!急!!!]AQL server 2008 R2 配置管理器无显示!!!!
- 求字符串处理
- SQL Server 2005 如何附加新组件
declare @tb table(i nvarchar(10))insert @tb
select 'a' union all
select 'b' union all
select 'c'declare @j nvarchar(10)
set @j = 'd'if((select count(1) from @tb where i = @j) <= 0)
set @j = '1'select @j
/*
--结果
1
*/
set @j = 'a'if((select count(1) from @tb where i = @j) <= 0)
set @j = '1'select @j
/*
--结果
a
*/
是不是 你要的结果...
SET @j = 'aa'
select @j = (case when a.Cnt = 0 then 1 else @j end) from ( select Cnt = count(1) from @tb where i = @j) a
对 你的意思就是用COUNT来解决,明白了 谢谢