locked
exec () AT LikedServer Failing RRS feed

  • คำถาม

  • DECLARE @SqlStr VARCHAR(Max)
    
    
    SET @SqlStr =
    
          'DECLARE @SQL varchar(max)
    
                            SET @SQL = '' CREATE SCHEMA  '' +SchemaName
                             PRINT (@SQL)
    						SET @metasql = ''
    							USE test
    							EXEC (''''' + REPLACE(@SqlStr, '''''', '''''''') + ''''')
    							''
    
    						EXEC (@metasql)
                      
    
          select @SQL = (SELECT ''select * into [db1].''+Schema_Name+''.''+ Table_Name + '' from #temp;'' + CHAR(10) + CHAR(13) from      [db2].[dbo].[table]
    
          FOR XML PATH(''''),TYPE).value(''.'',''varchar(max)'')
    
          EXEC (@SQL)'
    
    EXEC (@SqlStr) AT [GAALPSVR04CD]
    

    My code skeleton is something like this. When I am trying to execute this, I am getting below error.

    OLE DB provider "SQLNCLI11" for linked server "MyLikedServer" returned message "Command text was not set for the command object.".

    Msg 7215, Level 17, State 1, Line 68

    Could not execute statement on remote server 'MyLinkedServer'.

    17 กันยายน 2557 13:41

คำตอบ

ตอบทั้งหมด