I have a stored procedure running on SQL Server 2008 that returns a list of all procedures and their parameters:
procedure [dbo].[p_ListProcedures]
as
select
sp.name as 'Procedure',
p.name as 'Parameter',
t.name as 'Type',
p.is_output as 'Output',
dbo.GetParamDefault(p.name, object_definition(sp.object_id)) as 'Value'
from sys.procedures sp
left join sys.parameters p
on p.object_id=sp.object_id
left join sys.types t
on t.user_type_id=p.user_type_id
where sp.name like 'p_%'
order by sp.name
This procedure is ran on two different databases and is used to generate some ADO.NET code for us. It runs fine on one database, but on the other database, the last column Value
always returns the value of (what seems to be) the first row.
For this output:
- x, x, x, x, NULL
- x, x, x, x, NULL
- x, x, x, x, NULL
- x, x, x, x, NULL
- x, x, x, x, 'test'
- x, x, x, x, 'test'
- x, x, x, x, NULL
- x, x, x, x, NULL
Reading the values of the last column through a SqlDataReader (reader["Value"]
) will always return null when it should be retuning 'test' for rows 5 and 6.
I copied both databases to a local SQL Server Express 2012 install and the tool ran fine. So there is some peculiarity with that one database on the remote server that I just can't figure out.
Any ideas on what might be causing this to happen?