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 2012 Forums
 Transact-SQL (2012)
 Fetch valuses from different tables inside a FN

Author  Topic 

AAAV
Posting Yak Master

152 Posts

Posted - 2013-01-02 : 10:00:10
I have to have this in a Function and can not convert it to a procedure since it is used in a cross apply.

Depending on the value to a parameter say @provider
i have to get the values from table Provider_A or table Provider_B


select @strSQL='SELECT @mil_adj_12months= [mileage_adjusted_12]
FROM residual_value_mileage_adjustments'+@table_suffix +
' WHERE yearly_mileage=@actual_annual_mileage and mileage_category=@Mileage_Category'

execute(@strSQL)
Can it be done ?

AAAV
Posting Yak Master

152 Posts

Posted - 2013-01-02 : 10:30:52
Solved it ....

I created a view with one extra column specifying which provider it is.

now in all the sqls qualified with the provider.

Thanks
Go to Top of Page
   

- Advertisement -