create procedure [dbo].[sp_getstatemonthsp]
(@zzjgdm varchar(255),
@tablesname varchar(255) -- 表名應為 statemonth)as
begin
-- exec sp_droplinkedsrvlogin statdata_server,null
-- exec sp_dropserver statdata_server
-- exec sp_addlinkedserver
-- @server='statdata_server',--被訪問的伺服器別名
-- @srvproduct='',
-- @provider='statdata_server',
-- @datasrc='203.175.145.174' --要訪問的伺服器
-- exec sp_serveroption 'statdata_server','rpc out','true'
-- exec sp_serveroption 'statdata_server','rpc','true'
-- exec sp_addlinkedsrvlogin
-- 'statdata_server', --被訪問的伺服器別名
-- 'false',
-- null,
-- 'stat', --帳號
-- '687459219' --密碼
-- declare @sql varchar(1000)
-- declare @tempcode varchar(255)
-- --set @tempcode=(select top 1 hgdm from qyjbb where zzjgdm=@zzjgdm)
-- set @tempcode = dbo.funcfromjgdmtohgdm(@zzjgdm)
-- print @tempcode
-- if @tempcode=null or @tempcode=''
-- begin
-- set @tempcode='0000000000'
-- end
----print @tempconnstring
-- --set @sql = 'select * from openquery([203.175.145.174],''set fmtonly off;set nocount on;exec statdata.dbo.singlecorpiedatamonth ' + @tempcode + ''') as statemonth for xml auto'
-- set @sql = 'select * from openquery(statdata,''set fmtonly off;set nocount on;exec statdata.dbo.singlecorpiedatamonth ' + @tempcode + ''') as statemonth '
-- print @sql
-- exec(@sql)
--end
動態sql在儲存過程中的實現
這種情況下,如何轉為儲存過程呢?以上面的兩個動態為例,在儲存過程中實現如下 create or replace procedure my procedure1 tablename in varchar2,studentname in varchar2,my cursor1 out my proced...
oracle 在儲存過程中定義動態sql
表結構 create table item prop pid integer,name varchar2 20 is key prop integer,is sale prop integer,is color prop integer,parent pid integer,parent vid v...
在ORACLE儲存過程中建立臨時表
create procedure pro asstr varchar2 100 begin str create global temporary table tablename col1 varchar2 10 col2 number on mit preserve rows execute im...