26
Views
7
Comments
Pass database schema name as parameter in advance sql
Application Type
Traditional Web, Reactive

Hi Everyone,

Is there any way to pass database schema name as parameter in advance sql.

Below are executed sql


Just need to pass dbo(database schema) as parameter means dymanically.

Any help is really appreciated.


Regards

Shashi Kant Shukla 

Hi, Please try with sample as below screenshot: 

Getting below error

Hi, sorry as my first assumption is that either:

- Your environment is OnPrem and you have set up your own Schema (TestClient1.Public) in the DB.
- Or, your module is connected to an external DB connection.
If so, please make sure that we have schema TestClient1.Public exist in the DB.


It is already there but still getting same error

Hi, May I know if that Table is included in the External DB Connection extension.

 Yes that table included in External DB Connection extension 


Hi Shashi, 

I figured out the mechanism behind this. As for now, we have many DB connections (the default one and the external one) so that the AdvancedSQL action need some thing to "hint" which connection should be use. Based on this, I think we can work around like this:

with cte as(
-- With {Employee} is an Entity of the External DB that we want to dynamically select Schema
-- or Tabe, this will hint AdvanceSQL to use this connection for the rest of the Query 
SELECT TOP 1 {Employee}.[Id] 
FROM {Employee }
)

SELECT * FROM @DataBase.@Schema.@Table


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.