Solved

SSRS 2008 - Passing multi valued uniqueidentifier parameter to stored procedure

Posted on 2014-11-23
6
721 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 37

Expert Comment

by:ValentinoV
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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 extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

763 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

7 Experts available now in Live!

Get 1:1 Help Now