[英]INSERT INTO @Temp_Table VALUES from multi value SSRS Parameter
i'm building a report using ssrs report builder where in the code there is a part where i have to insert into a temp table some values.我正在使用 ssrs 报告生成器构建报告,其中在代码中有一部分我必须将一些值插入到临时表中。 these values should be loaded from a multi value parameter DatabaseName.
这些值应该从多值参数 DatabaseName 加载。 i tried the below code:
我尝试了以下代码:
DECLARE @Rep_Temp TABLE(SurrogateKeyIDENTITY int not null IDENTITY (1,1),tempDBName nvarchar(100) NOT NULL);
INSERT INTO @Rep_Temp (tempDBName) VALUES (@DatabaseName);
it works only if i select one value, when i select multiple value it will give error.只有当我选择一个值时它才有效,当我选择多个值时它会出错。
i also tried the below code with no success:我也尝试了以下代码但没有成功:
INSERT INTO @Rep_Temp (tempDBName) VALUES (join(Parameters!DatabaseName.Value,","));
appreciate your assistance.感谢您的帮助。
Best regards,此致,
Hi can you try this solution?嗨,你能试试这个解决方案吗? Turning a multi-value parameter into a temp table in SQL Server Business Intelligence Development Studio
在 SQL Server Business Intelligence Development Studio 中将多值参数转换为临时表
I solve it as per the below:我按照以下方法解决:
@DBNameString = join(Parameters!DatabaseName.Value,",")
@DBNameString = join(Parameters!DatabaseName.Value,",")
DECLARE @Rep_Temp TABLE(SurrogateKeyIDENTITY int not null IDENTITY (1,1),tempDBName nvarchar(100) NOT NULL);声明@Rep_Temp TABLE(SurrogateKeyIDENTITY int not null IDENTITY (1,1),tempDBName nvarchar(100) NOT NULL);
DECLARE @DBs VARCHAR(500);
DECLARE @DBName VARCHAR(500);
DECLARE @charSpliter CHAR;
SET @charSpliter = ','
SET @DBs = @DBNameString + @charSpliter;
WHILE CHARINDEX(@charSpliter, @DBs) > 0
BEGIN
SET @DBName = SUBSTRING(@DBs, 0, CHARINDEX(@charSpliter, @DBs))
SET @DBs = SUBSTRING(@DBs, CHARINDEX(@charSpliter, @DBs) + 1, LEN(@DBs))
INSERT INTO @Rep_Temp (tempDBName) VALUES (@DBName);
END
Best Regards,此致,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.