Solved

SSRS 2008 - Passing multi valued uniqueidentifier parameter to stored procedure

Posted on 2014-11-23
6
767 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
  • 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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now