cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
vasanthakumarmk
Active participant

How to use variable inside SQL Query?

Jump to solution

Hello,

I would like to use SQL Query with using the variable. I have mentioned below my query and expectations 

1. Replace EMPLOYEE to my variable:- 

String nameEmp = "ourEmployee";
 Actual query : szSQL="select name from sys.sysdatabases where name='EMPLOYEE'";
Expected : szSQL="select name from sys.sysdatabases where name=  ??????? ";
How to assign nameEmp variable to where name ?

2. Replace EMPLOYEE to my variable:- 
 String nameEmp = "ourEmployee";
 Actual query : "SELECT * FROM EMPLOYEE.INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME ='MetaDataTable'" ; 
Expected Query: "SELECT * FROM ???????????.INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME ='MetaDataTable'" ;
How to assign nameEmp variable to EMPLOYEE ?

3. Replace EMPLOYEE to my variable:-
String nameEmp = "ourEmployee";
Actual query :  "SELECT * FROM [EMPLOYEE].[dbo].[MetaDataTable]";
Expected query :  "SELECT * FROM [???????].[dbo].[MetaDataTable]";

How to assign nameEmp variable to EMPLOYEE ?

Regards,
Vasanth

0 Kudos
1 Solution

Accepted Solutions
rguggisberg
Intrepid explorer

Re: How to use variable inside SQL Query?

Jump to solution
I don't quite follow. Is the employee known at install time (input by user)? If so you can use 'Text Replacement' for your script in the 'SQL Scripts' view.

View solution in original post

0 Kudos
2 Replies
rguggisberg
Intrepid explorer

Re: How to use variable inside SQL Query?

Jump to solution
I don't quite follow. Is the employee known at install time (input by user)? If so you can use 'Text Replacement' for your script in the 'SQL Scripts' view.

View solution in original post

0 Kudos
vasanthakumarmk
Active participant

Re: How to use variable inside SQL Query?

Jump to solution
Thank you....
0 Kudos