SQL Server--向表添加新列和数据记录的存储过程(3)

create proc AddCloumnProc
(
   @tablename varchar(50),
   @columnname varchar(50)
)
as 
begin
exec ('alter table '+@tablename+' and '+@columnname)
end

 

create proc p_test
(
@id nvarchar(20),@sex bit,@age int
@address int,@phone  nvarchar(11)
@post  nvcarchar(16),@qq nvcarchar(12)

)
as
begin try
begin tran

insert into tb1 select @id,@sex,@age
insert into tb2 select @id,@address,@phone
insert into tb3 select @id,@post,@qq
commit
end try
begin catch
rollback
print '异常回滚'

end catch

 

posted @ 2016-04-10 22:41  不要太嚣张了  阅读(383)  评论(0编辑  收藏  举报