我不知道如何配置该OpenQuery
功能。
我想用来OpenQuery
在测试项目中查询数据库。但我不知道如何配置 servername 参数
DECLARE @Sql varchar(max)
DECLARE @SQLExcuteSentence varchar(max)
SET @Sql = 'declare @UserID INT
select @UserID = 1
declare @TotalGroupByFields nvarchar(2000)
select @TotalGroupByFields = ''Media''
declare @CostDataFileds nvarchar(2000)
select @CostDataFileds = ''''
declare @OtherDataFields nvarchar(max)
select @OtherDataFields = ''MonitoringSpotNumber,MonitoringTotalSeconds,BaseCost,ColourLoading,PositionLoading,WeekendLoading,Discount''
declare @MasterFilterId nvarchar(max)
select @MasterFilterId =''DateRange=20060601-20121231''+char(13)+''IncludeGuests=0''
declare @RatingTargetId nvarchar(2000)
select @RatingTargetId =''''
declare @IsEnableFinancialCloseDate INT
select @IsEnableFinancialCloseDate = 0
declare @MasterDisplayFormat nvarchar(2000)
select @MasterDisplayFormat = ''5''
exec [dbo].[USP_MatrixReport] @UserID, @TotalGroupByFields, @CostDataFileds, @OtherDataFields, @MasterFilterId, @RatingTargetId, @IsEnableFinancialCloseDate, @MasterDisplayFormat, 0'
SET @SQLExcuteSentence = 'SELECT * FROM OPENQUERY(SQLConn,' + '''' + @Sql + '''' + ')'
EXEC (@SQLExcuteSentence);
SQLConn 是什么?