Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Stored Proc to return different data types

Author  Topic 

dhw
Constraint Violating Yak Guru

332 Posts

Posted - 2009-08-26 : 18:43:45
Hello -

There is a table that contains configuration settings for an application. Some of the attributes and their datatypes are:
  • MaxPasswordLength (tinyint)
  • LastUpdate (datetime)
  • RestrictUsers (bit)
  • OrgName(nvarachar)


I was thinking of having a single stored proc where the calling app could just pass in the Column Name as the parameter and then I'd return whatever value it wants. The problem I am running into is the different data types. I could return everything as a string, but I was thinking that there might be a better solution?

Any suggestions would be appreciated.
Thanks
- will

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2009-08-26 : 20:07:24
You could return a record set to the application:

CREATE MyProc @Columnname sysname
as
begin
select MaxPasswordLength, LastUpdate, RestrictUsers, OrgName
from dbo.MyTable
where ColName = @ColumnName
end

=======================================
Men build too many walls and not enough bridges. -Isaac Newton, philosopher and mathematician (1642-1727)
Go to Top of Page
   

- Advertisement -