Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SSRS 2008 - Passing multi valued uniqueidentifier parameter to stored procedure

Posted on 2014-11-23
6
Medium Priority
?
1,006 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 800 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 1200 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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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 combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

885 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