对象没有列,或者当前用户没有该对象的权限

时间:2018-01-08 15:33:42

标签: sql-server stored-procedures

基本上我将当前的数据库传递给过程,从#clients_pom获取数据并更新它,但是......

  

Msg 7357,Level 16,State 2,Line 2   无法处理对象" SET FMTONLY OFF;设置NOCOUNT ON; EXEC WBANKA_KBBL2.dbo.sp_kbbl_WachLista_Priprema' 2017-09-30',' 2017-09-30',0"。 OLE DB提供程序" SQLNCLI"对于链接服务器"(null)"表示该对象没有列,或者当前用户没有该对象的权限。

DECLARE @SQL VARCHAR(MAX)
DECLARE @Datum varchar(20)
SET @Datum= '2017-09-30'

 IF OBJECT_ID('tempdb..##WL_Klijenti') IS NOT NULL DROP TABLE ##WL_Klijenti

 SELECT @SQL = '
    SELECT * 
      INTO ##WL_Klijenti
   FROM  OPENROWSET (''SQLOLEDB'',''Server=
  (local);TRUSTED_CONNECTION=YES;'',''SET FMTONLY OFF; SET NOCOUNT ON; EXEC 
  ' + DB_NAME()+'.dbo.sp_kbbl_WachLista_Priprema ''''' + @Datum + ''''', 
  ''''' + @Datum + ''''', 0'')
  AS tbl'

  EXEC(@SQL)

  UPDATE C
  SET C.watchListStatus = '1'
  FROM #clients_pom AS C
  INNER JOIN ##WL_Klijenti AS WL ON WL.mbr = C.registrationNumber

  IF OBJECT_ID('tempdb..##WL_Klijenti') IS NOT NULL DROP TABLE ##WL_Klijenti

0 个答案:

没有答案