当前位置: 代码迷 >> Sql Server >> 大伙儿看看这个经典吗?都是自己总结的。供大家学习
  详细解决方案

大伙儿看看这个经典吗?都是自己总结的。供大家学习

热度:45   发布时间:2016-04-25 00:53:10.0
大家看看这个经典吗?都是自己总结的。供大家学习
if exists(select * from sys.procedures where name='c')
drop proc c
go
create proc c
as
if db_id(N'a')is not null
drop database a
go
create database a
on
(name='a',
filename='d:\a.mdf',size=8,maxsize=9,filegrowth=5)
log on
(name='aa',
filename='d:\aa.ldf',size=7,maxsize=8,filegrowth=5)
go
use a
go
if exists(select * from sys.tables where name='w')
drop table w
go
select * into w from test.dbo.stu where 1=2     --test数据库里有表stu
go
insert into w(name,age,sex,address)
select name,age,sex,address from test.dbo.stu
except
select name,age,sex,address from w
go


------最佳解决方案--------------------
不管经典不经典,自己多总结总是有好处滴
------其他解决方案--------------------
恩恩,和你学到好多东西,我的分数基本都给你你了。应该的啊。呵呵
------其他解决方案--------------------
同意楼上的,DBA姐姐确实才高八斗啊
------其他解决方案--------------------
引用:


哇,走到哪里都能看到你啊!



拉一下!
------其他解决方案--------------------


------其他解决方案--------------------
这个存储过程有个问题,复制上粘贴可以执行成功
继而可以看到表w里的数据

但是调用存储过程显示成功,但是执行完都没有a这个数据库
这是为什么呢?
------其他解决方案--------------------
有人吗 求解啊
------其他解决方案--------------------
在 过程、函数或触发器 中不允许使用 USE database 语句。
------其他解决方案--------------------
null
  相关解决方案