SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Fetch valuses from different tables inside a FN
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic   

AAAV
Posting Yak Master

148 Posts

Posted - 01/02/2013 :  10:00:10  Show Profile  Reply with Quote
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 ?

Edited by - AAAV on 01/02/2013 10:01:17

AAAV
Posting Yak Master

148 Posts

Posted - 01/02/2013 :  10:30:52  Show Profile  Reply with Quote
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
  Previous Topic Topic   
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000