您的位置:首页 > 数据库

解决sql server中批处理过程中“'CREATE/ALTER PROCEDURE 必须是查询批次中的第一个语句”

2017-09-20 14:52 501 查看
-----------------------------------------line-------------------------------------------------
USE [p20-cy-2966];
/*
V1.0.2版本SQL批处理
*/

--判断某表的某字段是否存在
if (not exists(select * from syscolumns where id=object_id('BlanceManageO2O') and name='OrderInfoNum'))
ALTER TABLE BlanceManageO2O ADD OrderInfoNum INT DEFAULT 0;

GO

--判断某存储过程是否存在
if (exists (select * from sys.objects where name = 'sp_BlanceOrderInsertCatering'))
drop proc sp_BlanceOrderInsertCatering
GO
CREATE PROCEDURE [dbo].[sp_BlanceOrderInsertCatering]
-- 由存储过程SettlementManageO2O 中传入值
@ShopId int,
@AgentId int,
@BlanceId int,
@IndustryId int,  --行业类型 行业Id 1-零售 2-餐饮 3-酒店 4-娱乐 5-家政 6-旅游 7-二手
@Year	int,	                                    --年
@Month  int,	                                    --月
@Day	int	,                                       --日
@O2OShopPercent decimal(18,2),                      --020提成百分比
@WeixinPoundaga decimal(18,2),                      -- 获取系统设置PlatBaseSet表中的微信支付手续费百分比
@TransferPriceSum     decimal(18,2) output
AS
BEGIN
--处理程序
END

GO

--判断某存储过程是否存在
if (exists (select * from sys.objects where name = 'SettlementManageCatering'))
drop proc SettlementManageCatering
GO
CREATE PROCEDURE [dbo].[SettlementManageCatering]
AS
BEGIN
--处理程序
END

GO

-----------------------------------------line-------------------------------------------------

USE [p20-cy-2967];
/*
V1.0.2版本SQL批处理
*/

--判断某表的某字段是否存在
if (not exists(select * from syscolumns where id=object_id('BlanceManageO2O') and name='OrderInfoNum'))
ALTER TABLE BlanceManageO2O ADD OrderInfoNum INT DEFAULT 0;

GO

--判断某存储过程是否存在
if (exists (select * from sys.objects where name = 'sp_BlanceOrderInsertCatering'))
drop proc sp_BlanceOrderInsertCatering
GO
CREATE PROCEDURE [dbo].[sp_BlanceOrderInsertCatering]
-- 由存储过程SettlementManageO2O 中传入值
@ShopId int,
@AgentId int,
@BlanceId int,
@IndustryId int,  --行业类型 行业Id 1-零售 2-餐饮 3-酒店 4-娱乐 5-家政 6-旅游 7-二手
@Year	int,	                                    --年
@Month  int,	                                    --月
@Day	int	,                                       --日
@O2OShopPercent decimal(18,2),                      --020提成百分比
@WeixinPoundaga decimal(18,2),                      -- 获取系统设置PlatBaseSet表中的微信支付手续费百分比
@TransferPriceSum     decimal(18,2) output
AS
BEGIN
--处理程序
END

GO

if (exists (select * from sys.objects where name = 'SettlementManageCatering'))
drop proc SettlementManageCatering
GO
CREATE PROCEDURE [dbo].[SettlementManageCatering]
AS
BEGIN
--处理程序
END

GO
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐