存储过程只是节约大量SQL语句的传输时间.如果数据库和IIS是一台机器就无所谓
解决方案 »
- 如果导出几千万条数据,该用什么方法
- |zyciis| 如何给自己写的控件添加子控件你Repeater的样的Item标签
- 关于DataRowview和GridViewRow的问题。
- 问一VS2008安装后的IE出现的问题--超郁闷!!
- 求一个 可以与数据库链接的 焦点新闻
- 据说C#无法解决,问了一天了,没人会,不知道这边有人能提点我一二吗
- 一个button之后 先执行javascript 再执行server 后台script ?
- 办公系统中怎样显示给用户附件
- RDLC报表 子报表的总页码数如何传递给主报表
- 数据验证问题
- 用Discuz!NT 论坛的问题
- 如何用C#提取网页的所有内容(包括链接和文字内容)
CREATE procedure test
(
@str varchar(20)
) as
@s int
select @s=count(*) from table1 where fname=@str
if @s>0
begin
.....
end大概就这样,其中逻辑判断你就自己写吧
--在测试之前,把Job表的ID=14的列删除了,然后新建一个job_id=15的列
select * from jobs
select * from employeedeclare @max int,@i int,@id int
set @i=1
select @max=max(cou) from view_aaa
while @i<=@max
begin
select @id=job_id from view_aaa where cou=@i
print @id
if exists(select * from employee where job_id=@id)
begin
print '有--'
Set @i=@i+1
continue
end
print '没有'
Set @i=@i+1
end
create view view_aaa
as
SELECT cou=COUNT(*), hyt.job_id, hyt.min_lvl
FROM jobs AS hyt, jobs as czy
WHERE hyt.job_id>= czy.job_id
GROUP BY hyt.job_id, hyt.min_lvl
GO
测试结果--------------------希望对你有帮助
job_id=1
没有
job_id=2
有--
job_id=3
有--
job_id=4
有--
job_id=5
有--
job_id=6
有--
job_id=7
有--
job_id=8
有--
job_id=9
有--
job_id=10
有--
job_id=11
有--
job_id=12
有--
job_id=13
有--
job_id=15
没有
@str varchar(50)
AS
BEGINSET NOCOUNT ON
DECLARE @sql varchar(8000)
DECLARE @fcc varchar(100)set @sql=''if exists(select * from table2 where fname=@str)
begin
DECLARE c cursor fast_forward from select fcc from table2 where fname=@str
open c
fetch next from c into @fcc
while @fetch_status=0
begin
set @sql='select * from table1 where fname='+@str+' '
set @sql=@sql+' and fcc='+@fcc+' 'if exists(exec(@sql))
update table3 set fcount=fcount+1 where fcc=@str
else
insert into table3(fcc,fcount) values(@str,1); fetch next from c into @fcc
end
close c
deallocate c
endEND
GO仅供参考