当我作为参数传递给 sp_execute 时,我找不到服务器名称(我已将服务器添加为链接服务器)。当我传递一个硬编码的服务器名称时,它会被执行。
SET @PARMDEFINITION =N'@SOURCE_SERVER_NAME_IN VARCHAR(100), @SOURCE_DB_NAME_IN VARCHAR(100) ,@DESTI_SERVER_NAME_IN VARCHAR(100), @DESTI_DB_NAME_IN VARCHAR(100),
@DESTI_STUDENT_COUNT_OUT INT OUTPUT,@SOURCE_STUDENT_COUNT_OUT INT OUTPUT';
SET @SQLSTRING='SELECT @SOURCE_STUDENT_COUNT_OUT=COUNT(*) FROM [@SOURCE_SERVER_NAME_IN].[@SOURCE_DB_NAME_IN].DBO.STUDENT_MST WHERE CONVERT(FLOAT, RANK) <> 0 AND PAID2 =''S'''
EXECUTE SP_EXECUTESQL @SQLSTRING,@PARMDEFINITION,@SOURCE_SERVER_NAME_IN=@SOURCE_SERVER_NAME,@DESTI_SERVER_NAME_IN=@DESTI_SERVER_NAME,
@SOURCE_DB_NAME_IN=@SOURCE_DB_NAME,@DESTI_DB_NAME_IN=@DESTI_DB_NAME ,
@SOURCE_STUDENT_COUNT_OUT=@SOURCE_STUDENT_COUNT OUTPUT,@DESTI_STUDENT_COUNT_OUT=@DESTI_STUDENT_COUNT OUTPUT;
在 sys.servers 中找不到服务器“+@servername +”
请指教。