建立儲存過程remotejetquery:
create
procedure [dbo].[remotejetquery]
@tableorquerystring int
=1,@provider_name nvarchar
(30)=n'microsoft.jet.oledb.4.0',
@datasource nvarchar
(40)=n'd:/demo/sqldemo/test.mdb',
@user_id nvarchar
(20)=n'admin',
@password nvarchar
(20)=n'',
@object nvarchar
(500)=n'pe_article' as
declare
@sqlstring nvarchar
(610) if
@tableorquerystring=1
set @sqlstring=n'select * from openrowset('
+''''
+@provider_name+
''''
+','
+''''
+@datasource+
''''
+';'
+''''
+@user_id+
''''
+';'
+''''
+@password+
''''
+','
+@object+
')'; if
@tableorquerystring=2
set @sqlstring=n'select * from openrowset('
+''''
+@provider_name+
''''
+','
+''''
+@datasource+
''''
+';'
+''''
+@user_id+
''''
+';'
+''''
+@password+
''''
+','
+@object+
')';
exec
sp_executesql @sqlstring; go
執行儲存過程 remotejetquery
:sp_configure
'show advanced options'
,1;go
reconfigure;
go sp_configure
'ad hoc distributed queries'
,1;go
reconfigure;
go exec
demo.dbo.remotejetquery;go
exec
demo.dbo.remotejetquery 1,
default,
default,
default,
default,
n'pe_class';go
exec
demo.dbo.remotejetquery 2,
default,
default,
default,
default,
n'select classname from pe_class order by classid desc';go
sp_configure
'ad hoc distributed queries'
,0;go
reconfigure;
go sp_configure
'show advanced options'
,0;go
reconfigure;
go
SQL 2005 儲存過程分頁
create procedure dbo p pagetest sql nvarchar max sql語句不包括排序 curpage int,當前頁 pagerows int,頁面尺寸 order nvarchar 20 排序字段 ordertype nvarchar 10 排序型別倒序desc或...
SQL 2005 多表分頁儲存過程
region 返回所有職位物件 帶分頁 region 返回所有職位物件帶分頁 當前頁 每頁顯示數 返回 頁數 返回總項數 物件集合 public static listgetallmodel int curpage,int size,ref int pagesize,ref int totalsiz...
SQL2005 分頁儲存過程
最近在使用sqlserver2005的資料庫編碼,查到有乙個row number order by 字段 的函式,通過該函式進行分頁非常的方便,請大家看看我寫的分頁儲存過程。分頁儲存過程 create procedure dbo proc testpage 表名 tablename nvarchar...