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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

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

Posting Yak Master

152 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'

Can it be done ?

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

Posting Yak Master

152 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.

Go to Top of Page
  Previous Topic 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.02 seconds. Powered By: Snitz Forums 2000