Solved

SSRS 2008 - Passing multi valued uniqueidentifier parameter to stored procedure

Posted on 2014-11-23
6
925 Views
Last Modified: 2014-11-25
Hi,

I am trying to pass a  multi valued parameter, with uniqueidentifier datatype, to a stored procedure and display result set in the report.

I followed instruction in link below and adapt it to my sample test data.
http://blog.hoegaerden.be/2009/11/21/reporting-on-data-from-stored-procedures-part-2/

I have provided in the attached word doc, the procedures, tablb, function and data and whatever done in the report or is required to create a sample.

the problem is that my report only displays the first record and I have no idea why?

I appreciate your help.guidTest.docx
0
Comment
Question by:shmz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 37

Expert Comment

by:ValentinoV
ID: 40461837
Your @id parameter should be a string, not uniqueidentifier.   Also, that @idList parameter is not used further down in the code so there's no reason to keep it.

Here's what the simplified SP would look like:
CREATE PROCEDURE [dbo].[myguidtestproc]
(
@id as varchar(max)
--, @idList varchar(max)
)
AS
BEGIN

select id, Name, profession from myguidtest
where id in (select * from dbo.list_to_tbl(@id) )

END

Open in new window

0
 

Author Comment

by:shmz
ID: 40461999
Requirement of my report for @id is to be uniqueidentifier, or i.e. I have to pass a uniqueidentifier data type to stored proc (that's where the whole problem started.)
0
 
LVL 37

Assisted Solution

by:ValentinoV
ValentinoV earned 200 total points
ID: 40462018
Okay, but the definition of your parameter inside the stored proc needs to be varchar because that's what it will receive from the SSRS engine.  Why would something like "I have to pass a uniqueidentifier data type to stored proc" be part of the report requirements?  Who told you to do it like that?  The string representation of a uniqueidentifier has the same meaning, right?
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 37

Expert Comment

by:ValentinoV
ID: 40462022
In addition to previous comment: the report parameter's data type is actually string, not uniqueidentifier, so there's no logical reason to define it as uniqueidentifier inside the stored proc.  Just try the code I posted earlier, it should work without any other modifications to the report.
0
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 300 total points
ID: 40464158
I concur - if you use uniqueidentifer as your database type, then you will curtail the number of items in @id to 1.

If you run this code:

declare @id as nvarchar(max)
set @id = '76315e3a-31aa-412c-9f44-9978058aa061, 67f099b0-6f0f-498f-b55b-f8fdbd92c1ac, e5321460-ae3e-4348-9f76-f9b2cd13a010'
declare @id_vc as uniqueidentifier
set @id_vc = CAST(@id as uniqueidentifier)
select @id_vc

Open in new window


You will see that all you will get is the first part of the string.

If you change all of the uniqueidentifer to nvarchar(max) in both FUNCTION [dbo].[list_to_tbl] and PROCEDURE [dbo].[myguidtestproc], your code will work.
0
 

Author Closing Comment

by:shmz
ID: 40465972
Thank you
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question