CREATE PROCEDURE myproc
@lcs char(12) output
as
select @lcs = license
from MyWork..car
where model='Mazda' and license in(select license
from MyWork..owns
where ss =(select ss
from MyWork..person
where name='JohnSmith')
)
delete from MyWork..car
where license=@lcsdelete from MyWork..accident
where aciddate =(select aciddate
from MyWork..acidlog
where license=@lcs)
and driver =(select driver
from MyWork..acidlog
where license=@lcs)delete from MyWork..acidlog
where license=@lcs and driver='JohnSmith'delete from MyWork..owns
where license=@lcs
----**调用
declare @aa char(12)
myproc @aa output
select @aa
----------------------------------------
或
CREATE PROCEDURE myproc
as
declare @lcs char(12)
select @lcs = license
from MyWork..car
where model='Mazda' and license in(select license
from MyWork..owns
where ss =(select ss
from MyWork..person
where name='JohnSmith')
)
delete from MyWork..car
where license=@lcsdelete from MyWork..accident
where aciddate =(select aciddate
from MyWork..acidlog
where license=@lcs)
and driver =(select driver
from MyWork..acidlog
where license=@lcs)delete from MyWork..acidlog
where license=@lcs and driver='JohnSmith'delete from MyWork..owns
where license=@lcsselect @lcs
commit;
@lcs char(12) output
as
select @lcs = license
from MyWork..car
where model='Mazda' and license in(select license
from MyWork..owns
where ss =(select ss
from MyWork..person
where name='JohnSmith')
)
delete from MyWork..car
where license=@lcsdelete from MyWork..accident
where aciddate =(select aciddate
from MyWork..acidlog
where license=@lcs)
and driver =(select driver
from MyWork..acidlog
where license=@lcs)delete from MyWork..acidlog
where license=@lcs and driver='JohnSmith'delete from MyWork..owns
where license=@lcs
----**调用
declare @aa char(12)
myproc @aa output
select @aa
----------------------------------------
或
CREATE PROCEDURE myproc
as
declare @lcs char(12)
select @lcs = license
from MyWork..car
where model='Mazda' and license in(select license
from MyWork..owns
where ss =(select ss
from MyWork..person
where name='JohnSmith')
)
delete from MyWork..car
where license=@lcsdelete from MyWork..accident
where aciddate =(select aciddate
from MyWork..acidlog
where license=@lcs)
and driver =(select driver
from MyWork..acidlog
where license=@lcs)delete from MyWork..acidlog
where license=@lcs and driver='JohnSmith'delete from MyWork..owns
where license=@lcsselect @lcs
commit;
解决方案 »
- 高手帮忙看下我的文件保存老是出错。。
- 100分求高手请求一个SQL语句
- SQL Server2005的Analysis Services是否支持Crystal report 9
- t-sql动态横表变竖表的问题
- sqlserver2003,我设置关闭日志之后执行语句提示日志满
- sql查询中对数据处理问题
- real类型如何转换成 datetime类型?
- 查找一段时间怎么写?
- 取消重复数据后的数据处理问题。。急!!!!(在线等待)
- 一个小问题,关于数据类型转换
- 数据库导入导出的时候,其中的存储过程为什么不能够随着表,视图导入导出?
- ¥¥高分:在繁体操作系统中,显示数据库中file字段value问题???
declare @aa char(12) output
as
declare @lcs char(12)
select @lcs = license
from MyWork..car
where model='Mazda' and license in(select license
from MyWork..owns
where ss =(select ss
from MyWork..person
where name='JohnSmith')
)
delete from MyWork..car
where license=@lcsdelete from MyWork..accident
where aciddate =(select aciddate
from MyWork..acidlog
where license=@lcs)
and driver =(select driver
from MyWork..acidlog
where license=@lcs)delete from MyWork..acidlog
where license=@lcs and driver='JohnSmith'delete from MyWork..owns
where license=@lcsset @aa=@lcs
commit;