当前位置: 代码迷 >> Sql Server >> 一个pro的疑问解决方案
  详细解决方案

一个pro的疑问解决方案

热度:96   发布时间:2016-04-27 15:46:51.0
一个pro的疑问
USE   MmyeeAd
GO
--   check   existing   of   sp_Import_MmyeeAd
IF   OBJECT_ID   (   'dbo.sp_Import_MmyeeAd ',   'P '   )   IS   NOT   NULL  
        DROP   PROCEDURE   dbo.sp_Import_MmyeeAd
GO

CREATE   PROCEDURE     dbo.sp_Import_MmyeeAd
@Provider_Name   nvarchar(50)   =   'SQLOLEDB ',
@DataSource   nvarchar(50)   =   '. ',
@User_ID   nvarchar(50)   = 'sa ',
@Password   nvarchar(50)= ' '
AS
BEGIN
          /*
                      --Function   Improt   WebUser
                      --relate   to   Three   Table   :   Corp_Info-----------> > Ad_WebSite+Accounts_Users
          */
                        --   select   A.*   from   OpenRowSet( 'SQLOLEDB ', 'ROBOTH\SQLEXPRESS '; 'saa '; '1q ', 'select   *   from   Mayee_Online.dbo.Corp_Info ')   AS   A
                     
          execute( 'select   A.*   from     OpenRowSet( '[email protected]_Name+ ', '[email protected]+ '; '[email protected]_ID+ '; '[email protected]+ ', ' 'select   *   from   Mayee_Online.dbo.Corp_Info ' ')   AS   A ')
END
GO

execute   dbo.sp_Import_MmyeeAd   'SQLOLEDB ', 'ROBOTH\\SQLEXPRESS ', 'saa ', '1q '

go
execute   dbo.sp_Import_MmyeeAd   'SQLOLEDB ', 'ROBOTH\SQLEXPRESS ', 'saa ', '1q '


2个都不对,执行时报错
消息   102,级别   15,状态   1,第   1   行
'ROBOTH '   附近有语法错误

------解决方案--------------------
try

USE MmyeeAd
GO
-- check existing of sp_Import_MmyeeAd
IF OBJECT_ID ( 'dbo.sp_Import_MmyeeAd ', 'P ' ) IS NOT NULL
DROP PROCEDURE dbo.sp_Import_MmyeeAd
GO

CREATE PROCEDURE dbo.sp_Import_MmyeeAd
@Provider_Name nvarchar(50) = 'SQLOLEDB ',
@DataSource nvarchar(50) = '. ',
@User_ID nvarchar(50) = 'sa ',
@Password nvarchar(50)= ' '
AS
BEGIN
/*
--Function Improt WebUser
--relate to Three Table : Corp_Info-----------> > Ad_WebSite+Accounts_Users
*/
-- select A.* from OpenRowSet( 'SQLOLEDB ', 'ROBOTH\SQLEXPRESS '; 'saa '; '1q ', 'select * from Mayee_Online.dbo.Corp_Info ') AS A

execute( 'select A.* from OpenRowSet( ' ' '[email protected]_Name+ ' ' ', ' ' '[email protected]+ ' ' '; ' ' '[email protected]_ID+ ' ' '; ' ' '[email protected]+ ' ' ', ' 'select * from Mayee_Online.dbo.Corp_Info ' ') AS A ')
END
GO

execute dbo.sp_Import_MmyeeAd 'SQLOLEDB ', 'ROBOTH\\SQLEXPRESS ', 'saa ', '1q '

go
execute dbo.sp_Import_MmyeeAd 'SQLOLEDB ', 'ROBOTH\SQLEXPRESS ', 'saa ', '1q '
  相关解决方案