minglelinch
asked on
report uniqueidentifier type pass
My report failed to returm any data due to a uniqueidentifier field parameter communication with store procedure.
Select cols, ...
From mytable
Where ( WorkID in (....)) --WorkID is uniqueidentifier data type
I have passed string parameter and int flag parameter to SP successfully.
For an uniqueidentifier field, I used the same way as a string parameter associated with a varchar type field does. But I failed.
What would be the right to pass the parameter coresponding to an uniqueidentifier field to SP?
Thanks.
Select cols, ...
From mytable
Where ( WorkID in (....)) --WorkID is uniqueidentifier data type
I have passed string parameter and int flag parameter to SP successfully.
For an uniqueidentifier field, I used the same way as a string parameter associated with a varchar type field does. But I failed.
What would be the right to pass the parameter coresponding to an uniqueidentifier field to SP?
Thanks.
ASKER
Thanks for posting. It's a nice thought for the above code.
I got error: Conversion failed when converting a character string to uniqueidentifier. I changed the join to
INNER JOIN dbo.fSplitString(@myUndent ifyer, ',') s ON Convert(varchar(1000),s.s) = Convert(varchar(1000),t.Wo rkID)
then the error is gone, but no data is returned. All t.WorkIDs are within 50 in length.
The function fSplitString should be fine, as I have other string filters using fSplitString work fine.
Then I changed the SP input parameter @myUndentifyer as nvarchar(MAX), I got error:
"An error has occurred during report processing. Cannot read the next data row for the dataset 'dsname'. The statement terminated. The Maximum recursion 100 has been exhausted before statement completion."
So is it data issue or length issue, or other issues? I'm still looking for further solution. I appreciate nay help.
I got error: Conversion failed when converting a character string to uniqueidentifier. I changed the join to
INNER JOIN dbo.fSplitString(@myUndent
then the error is gone, but no data is returned. All t.WorkIDs are within 50 in length.
The function fSplitString should be fine, as I have other string filters using fSplitString work fine.
Then I changed the SP input parameter @myUndentifyer as nvarchar(MAX), I got error:
"An error has occurred during report processing. Cannot read the next data row for the dataset 'dsname'. The statement terminated. The Maximum recursion 100 has been exhausted before statement completion."
So is it data issue or length issue, or other issues? I'm still looking for further solution. I appreciate nay help.
The Maximum recursion 100 has been exhausted before statement completion
Are you using a recursive CTE (Common Table Expression) somewhere? Perhaps in the fSplitString function? 100 recursions is the default. You can use the MAXRECURSION query hint to change this, see example C here: Query Hints (Transact-SQL)
Are you using a recursive CTE (Common Table Expression) somewhere? Perhaps in the fSplitString function? 100 recursions is the default. You can use the MAXRECURSION query hint to change this, see example C here: Query Hints (Transact-SQL)
ASKER
I do not use CTE here at all. I attached fSplitString function. It seems MAXRECURSION is option for cte.
fsplitstr.txt
fsplitstr.txt
ASKER
I changed the SP input parameter @myUndentifyer size from nvarchar(Max) to nvarchar(1000), the error is gone.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Nice article. Thanks for sharing.
I used your ParmsToListViaXML, but wondering the field name to get from SP.
I tried
INNER JOIN dbo.fSplitString(@myUndent ifyer, ',') s ON s.s = t.WorkID
also tried
Where (SSV.WorkID in (select rtrim(ltrim(s)) from dbo.ParmsToListViaXML(@Par am, ',')))
but s is complained as an invalid column name. I used result, val, value as column name, none of them works.
I used your ParmsToListViaXML, but wondering the field name to get from SP.
I tried
INNER JOIN dbo.fSplitString(@myUndent
also tried
Where (SSV.WorkID in (select rtrim(ltrim(s)) from dbo.ParmsToListViaXML(@Par
but s is complained as an invalid column name. I used result, val, value as column name, none of them works.
ASKER
I used Value in stead of value. Compile is fine when I used one of the three as below:
INNER JOIN dbo.ParmsToListViaXML(@Par am, ',') s ON s.Value = t.WorkID
WHERE (t.WorkID) in (select rtrim(ltrim(Value)) from dbo.ParmsToListViaXML(@Par am, ',')))
WHERE (Convert(varchar(555),t.Wo rkID) in (select rtrim(ltrim(Value)) from dbo.ParmsToListViaXML(@Par am, ',')))
But no data are returned when I run the report.
If I remove this filter in SP, report data are returned.
INNER JOIN dbo.ParmsToListViaXML(@Par
WHERE (t.WorkID) in (select rtrim(ltrim(Value)) from dbo.ParmsToListViaXML(@Par
WHERE (Convert(varchar(555),t.Wo
But no data are returned when I run the report.
If I remove this filter in SP, report data are returned.
"Value" is indeed the right field to use.
To debug this, create a new SP with simple code like:
To debug this, create a new SP with simple code like:
select * from dbo.ParmsToListViaXML(@Param, ',')
Set up a new dataset, connect it with your multi-GUID parameter, dump the output in a new table on the report and see what you get there.
ASKER
I did the above steps, data from ParmsToListViaXML(@Param, ',') are showing in the new table. So ParmsToListViaXML works as expected.
But if I uncommon the join -
INNER JOIN dbo.ParmsToListViaXML(@Par am, ',') s ON s.Value = t.WorkID
or uncommon
Where t.WorkID in (select rtrim(ltrim(Value)) from dbo.ParmsToListViaXML(@Par am, ','))
the report data is gone.
But if I uncommon the join -
INNER JOIN dbo.ParmsToListViaXML(@Par
or uncommon
Where t.WorkID in (select rtrim(ltrim(Value)) from dbo.ParmsToListViaXML(@Par
the report data is gone.
ASKER
Great solution.
My issue is caused by db data.
Thanks a lot for help.
My issue is caused by db data.
Thanks a lot for help.
Perhaps try rewriting your query like this:
Open in new window
Thanks to the INNER JOIN you'll only be getting records for the values returned by the fSplitString function.