Alter table [dbo].[Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_0] add [ITEM_015afb1d-28de-4389-a6a1-e2dbdd89fa06] nvarchar(200)
update [Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_0] set [Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_0].[ITEM_015afb1d-28de-4389-a6a1-e2dbdd89fa06] = (select [Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_2].[ITEM_015afb1d-28de-4389-a6a1-e2dbdd89fa06] from [Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_2] where [Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_2].[SYSTEM_ID] = [Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_0].[SYSTEM_ID])WHERE EXISTS (SELECT 1 FROM [Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_2] WHERE [dbo].[Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_2].[SYSTEM_ID] = [Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_0].[SYSTEM_ID])
update [Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_2] set [ITEM_015afb1d-28de-4389-a6a1-e2dbdd89fa06]=null
ALTER TABLE [dbo].[Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_2] DROP COLUMN [ITEM_015afb1d-28de-4389-a6a1-e2dbdd89fa06]
这四个sql语句怎样写在一个存储过程中
BEGIN TRY
BEGIN TRAN
/*SQL 脚本的删增改*/
COMMIT TRAN
END TRY
BEGIN CATCH
ROLLBACK TRAN
END CATCH
为什么提示说begin try有语法错误了
begin try
Alter table [dbo].[Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_0] add [ITEM_015afb1d-28de-4389-a6a1-e2dbdd89fa06] nvarchar(200)
update [Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_0] set [Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_0].[ITEM_015afb1d-28de-4389-a6a1-e2dbdd89fa06] = (select [Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_2].[ITEM_015afb1d-28de-4389-a6a1-e2dbdd89fa06] from [Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_2] where [Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_2].[SYSTEM_ID] = [Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_0].[SYSTEM_ID])WHERE EXISTS (SELECT 1 FROM [Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_2]WHERE [dbo].[Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_2].[SYSTEM_ID] = [Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_0].[SYSTEM_ID])
update [Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_2] set [ITEM_015afb1d-28de-4389-a6a1-e2dbdd89fa06]=null
ALTER TABLE [dbo].[Form_016336CC-C7FA-43D2-9EA5-C3F9A5B47A50_2] DROP COLUMN [ITEM_015afb1d-28de-4389-a6a1-e2dbdd89fa06]
COMMIT
end try
begin catch
rollback
end catch
@小菜鸟5: ods,你怎么把 BEGIN TRAN 给省略了,还有COMMIT TRAN ,ROLLBACK TRAN 写全好么,另你的MSSS 版本多少?
@英雄莫问出处: sql server2012
@英雄莫问出处: 我写全了也是一样的错误
@小菜鸟5: 怎么会了,我的2008 R2的OK 啊,你把你写的SQL语句单独一起执行可以吗
@英雄莫问出处: 单独可以
@英雄莫问出处: 报错是BEGIN附近有语法错误
@英雄莫问出处: 我知道了我掉了一个as
@小菜鸟5: 你把报错的整个语句发我看看,是不是漏了什么BEGIN/END
@英雄莫问出处: 我掉了一个AS,要在begin上加一个AS就不会报错了
直接创建一个新的存储过程,把你的sql语句放进去就OK了,不管几条,都可以
出现回滚怎样解决啊