IF EXISTS (SELECT name FROM sysobjects
WHERE name = '一般贸易默认值' AND type = 'P')
DROP PROCEDURE 一般贸易默认值
GO
CREATE PROCEDURE 一般贸易默认值
WITH ENCRYPTION
AS/**
出口表头默认值通过CDS用户表SYS_DEFAULT导入指定表sys_default_dec_e_head2
(一般贸易表头默认值)
**/if exists (select 1
from sysobjects
where id = object_id('sys_default_dec_e_head2')
and type = 'U')
drop table sys_default_dec_e_head2
go
select distinct c.[type] as TYPE,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'AGENT_CODE')as AGENT_CODE,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'AGENT_NAME')as AGENT_NAME,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'CUSTOM_MASTER')as CUSTOM_MASTER,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'CUSTOMS_CODE')as CUSTOMS_CODE,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'CUSTOMS_CODE.1')as 'CUSTOMS_CODE.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'CUT_MODE' )as CUT_MODE,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'CUT_MODE.1' )as 'CUT_MODE.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'DISTINATE_PORT' )as DISTINATE_PORT,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'DISTINATE_PORT.1' )as 'DISTINATE_PORT.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'DISTRICT_CODE' )as DISTRICT_CODE,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'DISTRICT_CODE.1' )as 'DISTRICT_CODE.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'ENTRY_TYPE' )as ENTRY_TYPE,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'I_E_PORT' )as I_E_PORT,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'I_E_PORT.1' )as 'I_E_PORT.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'MANUAL_NO' )as MANUAL_NO,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'OWNER_CODE' )as OWNER_CODE,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'OWNER_NAME' )as OWNER_NAME,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_CO' )as TRADE_CO,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_COUNTRY' )as TRADE_COUNTRY,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_COUNTRY.1' )as 'TRADE_COUNTRY.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_MODE' )as TRADE_MODE,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_MODE.1' )as 'TRADE_MODE.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_NAME' )as TRADE_NAME,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRAF_MODE' )as 'TRAF_MODE',
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRAF_MODE.1' )as 'TRAF_MODE.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRANS_MODE' )as TRANS_MODE,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRANS_MODE.1' )as 'TRANS_MODE.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'WRAP_TYPE' )as WRAP_TYPE
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'WRAP_TYPE.1' )as 'WRAP_TYPE.1'
into sys_default_dec_e_head2 from SYS_DEFAULT c where type = 'DEC_EX_HEAD'
go
/**
出口表头默认值通过CDS用户表SYS_DEFAULT导入指定表sys_default_dec_e_list2
(一般贸易表体默认值)
**/
if exists (select 1
from sysobjects
where id = object_id('sys_default_dec_e_list2')
and type = 'U')
drop table sys_default_dec_e_list2
go
select distinct c.[type] as TYPE,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'DUTY_MODE')as DUTY_MODE,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'ORIGIN_COUNTRY')as ORIGIN_COUNTRY,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_CURR')as TRADE_CURR,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'USE_TO')as USE_TO
into sys_default_dec_e_list2 from SYS_DEFAULT c where type = 'DEC_EX_LIST'
go我直接执行两条SQL语句都是正常,但在前面加了这段后就一直报错提示第一个SQL已存在表名IF EXISTS (SELECT name FROM sysobjects
WHERE name = '一般贸易默认值' AND type = 'P')
DROP PROCEDURE 一般贸易默认值
GO
CREATE PROCEDURE 一般贸易默认值
WITH ENCRYPTION
AS
SQL存储
WHERE name = '一般贸易默认值' AND type = 'P')
DROP PROCEDURE 一般贸易默认值
GO
CREATE PROCEDURE 一般贸易默认值
WITH ENCRYPTION
AS/**
出口表头默认值通过CDS用户表SYS_DEFAULT导入指定表sys_default_dec_e_head2
(一般贸易表头默认值)
**/if exists (select 1
from sysobjects
where id = object_id('sys_default_dec_e_head2')
and type = 'U')
drop table sys_default_dec_e_head2
go
select distinct c.[type] as TYPE,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'AGENT_CODE')as AGENT_CODE,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'AGENT_NAME')as AGENT_NAME,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'CUSTOM_MASTER')as CUSTOM_MASTER,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'CUSTOMS_CODE')as CUSTOMS_CODE,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'CUSTOMS_CODE.1')as 'CUSTOMS_CODE.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'CUT_MODE' )as CUT_MODE,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'CUT_MODE.1' )as 'CUT_MODE.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'DISTINATE_PORT' )as DISTINATE_PORT,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'DISTINATE_PORT.1' )as 'DISTINATE_PORT.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'DISTRICT_CODE' )as DISTRICT_CODE,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'DISTRICT_CODE.1' )as 'DISTRICT_CODE.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'ENTRY_TYPE' )as ENTRY_TYPE,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'I_E_PORT' )as I_E_PORT,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'I_E_PORT.1' )as 'I_E_PORT.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'MANUAL_NO' )as MANUAL_NO,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'OWNER_CODE' )as OWNER_CODE,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'OWNER_NAME' )as OWNER_NAME,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_CO' )as TRADE_CO,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_COUNTRY' )as TRADE_COUNTRY,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_COUNTRY.1' )as 'TRADE_COUNTRY.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_MODE' )as TRADE_MODE,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_MODE.1' )as 'TRADE_MODE.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_NAME' )as TRADE_NAME,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRAF_MODE' )as 'TRAF_MODE',
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRAF_MODE.1' )as 'TRAF_MODE.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRANS_MODE' )as TRANS_MODE,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRANS_MODE.1' )as 'TRANS_MODE.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'WRAP_TYPE' )as WRAP_TYPE
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'WRAP_TYPE.1' )as 'WRAP_TYPE.1'
into sys_default_dec_e_head2 from SYS_DEFAULT c where type = 'DEC_EX_HEAD'
go
/**
出口表头默认值通过CDS用户表SYS_DEFAULT导入指定表sys_default_dec_e_list2
(一般贸易表体默认值)
**/
if exists (select 1
from sysobjects
where id = object_id('sys_default_dec_e_list2')
and type = 'U')
drop table sys_default_dec_e_list2
go
select distinct c.[type] as TYPE,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'DUTY_MODE')as DUTY_MODE,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'ORIGIN_COUNTRY')as ORIGIN_COUNTRY,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_CURR')as TRADE_CURR,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'USE_TO')as USE_TO
into sys_default_dec_e_list2 from SYS_DEFAULT c where type = 'DEC_EX_LIST'
go我直接执行两条SQL语句都是正常,但在前面加了这段后就一直报错提示第一个SQL已存在表名IF EXISTS (SELECT name FROM sysobjects
WHERE name = '一般贸易默认值' AND type = 'P')
DROP PROCEDURE 一般贸易默认值
GO
CREATE PROCEDURE 一般贸易默认值
WITH ENCRYPTION
AS
SQL存储
2:创建好存储过程后,进入存储过程,看看创建的存储过程,是否语句和自己写的代码是否一样
3:你的存储过程,貌似是多条语句,但你没有除用begin end
crate proc aa as
begin
语句1
语句2
end
IF EXISTS (SELECT name FROM sysobjects
WHERE name = '一般贸易默认值' AND type = 'P')
DROP PROCEDURE 一般贸易默认值
GO
CREATE PROCEDURE 一般贸易默认值
WITH ENCRYPTION
AS
/**
出口表头默认值通过CDS用户表SYS_DEFAULT导入指定表sys_default_dec_e_head2
(一般贸易表头默认值)
**/if exists (select 1
from sysobjects
where id = object_id('sys_default_dec_e_head2')
and type = 'U')
drop table sys_default_dec_e_head2
go
select *
into sys_default_dec_e_head2 from SYS_DEFAULT c where type = 'DEC_EX_HEAD'
go
/**
出口表头默认值通过CDS用户表SYS_DEFAULT导入指定表sys_default_dec_e_list2
(一般贸易表体默认值)
**/
if exists (select 1
from sysobjects
where id = object_id('sys_default_dec_e_list2')
and type = 'U')
drop table sys_default_dec_e_list2
go
select *
into sys_default_dec_e_list2 from SYS_DEFAULT c where type = 'DEC_EX_LIST'其实就是这个SQL,这个很简化的;
IF EXISTS (SELECT name FROM sysobjects
WHERE name = '一般贸易默认值' AND type = 'P')
DROP PROCEDURE 一般贸易默认值
GO
CREATE PROCEDURE 一般贸易默认值
WITH ENCRYPTION
AS/**
出口表头默认值通过CDS用户表SYS_DEFAULT导入指定表sys_default_dec_e_head2
(一般贸易表头默认值)
**/if exists (select 1
from sysobjects
where id = object_id('sys_default_dec_e_head2')
and type = 'U')
drop table sys_default_dec_e_head2
else
begin
select distinct c.[type] as TYPE,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'AGENT_CODE')as AGENT_CODE,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'AGENT_NAME')as AGENT_NAME,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'CUSTOM_MASTER')as CUSTOM_MASTER,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'CUSTOMS_CODE')as CUSTOMS_CODE,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'CUSTOMS_CODE.1')as 'CUSTOMS_CODE.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'CUT_MODE' )as CUT_MODE,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'CUT_MODE.1' )as 'CUT_MODE.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'DISTINATE_PORT' )as DISTINATE_PORT,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'DISTINATE_PORT.1' )as 'DISTINATE_PORT.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'DISTRICT_CODE' )as DISTRICT_CODE,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'DISTRICT_CODE.1' )as 'DISTRICT_CODE.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'ENTRY_TYPE' )as ENTRY_TYPE,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'I_E_PORT' )as I_E_PORT,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'I_E_PORT.1' )as 'I_E_PORT.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'MANUAL_NO' )as MANUAL_NO,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'OWNER_CODE' )as OWNER_CODE,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'OWNER_NAME' )as OWNER_NAME,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_CO' )as TRADE_CO,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_COUNTRY' )as TRADE_COUNTRY,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_COUNTRY.1' )as 'TRADE_COUNTRY.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_MODE' )as TRADE_MODE,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_MODE.1' )as 'TRADE_MODE.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_NAME' )as TRADE_NAME,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRAF_MODE' )as 'TRAF_MODE',
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRAF_MODE.1' )as 'TRAF_MODE.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRANS_MODE' )as TRANS_MODE,
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRANS_MODE.1' )as 'TRANS_MODE.1',
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'WRAP_TYPE' )as WRAP_TYPE
--(select value from SYS_DEFAULT where [type] = c.[type] and name = 'WRAP_TYPE.1' )as 'WRAP_TYPE.1'
into sys_default_dec_e_head2 from SYS_DEFAULT c where type = 'DEC_EX_HEAD'
end
/**
出口表头默认值通过CDS用户表SYS_DEFAULT导入指定表sys_default_dec_e_list2
(一般贸易表体默认值)
**/
if exists (select 1
from sysobjects
where id = object_id('sys_default_dec_e_list2')
and type = 'U')
drop table sys_default_dec_e_list2
else
begin
select distinct c.[type] as TYPE,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'DUTY_MODE')as DUTY_MODE,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'ORIGIN_COUNTRY')as ORIGIN_COUNTRY,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'TRADE_CURR')as TRADE_CURR,
(select value from SYS_DEFAULT where [type] = c.[type] and name = 'USE_TO')as USE_TO
into sys_default_dec_e_list2 from SYS_DEFAULT c where type = 'DEC_EX_LIST'
end