Solved

SSRS 2008 - Passing multi valued uniqueidentifier parameter to stored procedure

Posted on 2014-11-23
6
820 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

830 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