I would like to create a stored procedure which utilizes some user defined functions if the DB version is 2000 if not don't look for the UDF.
The following example displays what I would like to do, but does not work. It seems that SQL server will try to find the UDF even if it not actually accessed for processing.
The solution I am trying to avoid is writing two version of the SP or one very long version with the select code duplicated once for sql 2000 and once for sql7.
The SP is designed to return a dataset.
Create my_proc (@myHandle integer )
AS
Declare @serverVersion varchar(7)
Select @serverVersion = case when @@version like 'Microsoft Sql Server 2000%' then 'sql2000' else 'sql7'
Begin
Select
field1,
field2,
....
field55
Case @serverVersion when 'sql2000' then dbo.my_UDF(field2 esle '' end
From table1
end
Any thought of how to achieve the same thing differently?
Keeping in mind that the actual SP will have about 55 fields and be unioned.
Thanks
The following example displays what I would like to do, but does not work. It seems that SQL server will try to find the UDF even if it not actually accessed for processing.
The solution I am trying to avoid is writing two version of the SP or one very long version with the select code duplicated once for sql 2000 and once for sql7.
The SP is designed to return a dataset.
Create my_proc (@myHandle integer )
AS
Declare @serverVersion varchar(7)
Select @serverVersion = case when @@version like 'Microsoft Sql Server 2000%' then 'sql2000' else 'sql7'
Begin
Select
field1,
field2,
....
field55
Case @serverVersion when 'sql2000' then dbo.my_UDF(field2 esle '' end
From table1
end
Any thought of how to achieve the same thing differently?
Keeping in mind that the actual SP will have about 55 fields and be unioned.
Thanks