Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have created a connection string in Txt file and calling it through include statement. And I have assigned a variable to this include statement using Let statement. But when I am calling the variable through $ expansion to use a connection sting it throwing an red error line. Please help me in this regard.
Set vtest=$(Include =C:\Users\Test\Desktop\Inlcude/Test.txt);
$(vtest);
Hari:
SELECT * from Db;
An alternative way is to use a SET statement in the Include file that sets a variable to the actual Connection string. Test.txt may contain something like:
SET vConnectionString = '[...]';
and in your Load Script, you can use that variable like this:
$(Include=C:\Users\Test\Desktop\Include\Test.txt)
OLEDB CONNECT TO $(vConnectionString);
Hari:
SELECT * FROM Db;
Always make sure that the syntax and path of the Include construct are correct. Or your variable will not be loaded and the CONNECT statement will fail.
Best,
Peter
Why do you need a variable? You can keep it simple by just specifying the following sequence:
$(Include=C:\Users\Test\Desktop\Include\Test.txt)
Hari:
SELECT * FROM Db;
This works only on condition that your Test.txt file contains a full connect statement, like for example:
OLEDB CONNECT TO [...];
Best,
Peter
use "must include" in your load statement. It will let you know if the load failed.
An alternative way is to use a SET statement in the Include file that sets a variable to the actual Connection string. Test.txt may contain something like:
SET vConnectionString = '[...]';
and in your Load Script, you can use that variable like this:
$(Include=C:\Users\Test\Desktop\Include\Test.txt)
OLEDB CONNECT TO $(vConnectionString);
Hari:
SELECT * FROM Db;
Always make sure that the syntax and path of the Include construct are correct. Or your variable will not be loaded and the CONNECT statement will fail.
Best,
Peter
Thank you the quick reply. Can we use Let instead of set in this scenario ?
Thanks
Yes, you can. Although the SET statement is more flexible when trying to stuff a string with pesky characters (quotes, double quotes, brackets) in a variable.
Best,
Peter
Thank you for the Help Peter.
Hi Hari,
1) First of all variable vtest is not necessary as Peter mentioned.
2) You cant use $(vtest). You have to assign to another variable using let or set
eg: Let vtest2 = $(vtest);
-Uva