I've got an MSSQL 2000 sproc that has a lot of repetition that can
probably be abstracted. Please let me know if there's a good way to do
this:

<this is just a snippet>
ALTER  PROC sp_DAexport

AS

SELECT
ID,
cast((round(cast(q7years as decimal) + (cast(q7months as decimal)/12),
1)) as decimal(18,1)) as q7,
cast((round(cast(q8years as decimal) + (cast(q8months as decimal)/12),
1)) as decimal(18,1)) as q8
FROM         dbo.Respondents

I'd like to wrap the math and maybe the aliasing into a sub-sproc
funtion, but I don't know if/how I can do it. Here's a _bad_ syntax
version of what I'm after:

SELECT
ID,
sp_calcYears('7'),
sp_calcYears('8')
FROM         dbo.Respondents

Thanks,
Jamie
______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to