sql query with in clause in oledb source ssis - tsql

Hope everyone is doing well. I am new in ssis and I am badly stuck.
I have a ssis package which has a Oracle oledb source and sql server oledb destination. The oracle oledb source has a parameterized sql query .
I have a string variable #resultset with a list of comma seperated id's which I have parsed from an execute sql task object variable. value of #resultset is like this 111,2222,333,444
I need to feed this string variable to the in clause in the parameterized source query.
I am using sql command from variable in the oledb source. I have stored the query as expression in a variable called #setquery.
The query is like this:
"select col1, col2, ...coln from oracledb.table
where colid in (" + #resultset + ")"
But I get an error when I try to see the columns."Unable to retrieve column information from data source"
I read that I can use dynamic sql and I tried it but I am not being able to do it right.
I am using sql server 2017 and visual studios for ssdt 2017.
Could you please help!!
Thank you!

try to set the OLEDB Setting : AlwaysUseDefaulCodePage to True!
Good luck

Related

How to fetch Select statement from variable for Copy data activity in Azure Data Factory?

I have source query in Copy data activity of Azure Data Factory. Currently it is static query, but I would like to get entire statement from database and use that in Query in Activity.
I try to pass SQL statement as variable there is issue.
Lookup SQL Query for fetching Select statement:
SELECT [source_query] FROM [SalesLT].[configuration] WHERE [Id] = '1'
Query returns and set variable:
SELECT Count(CustomerId) Source_Rows FROM [SalesLT].[Customer]
Error with Copy data:
Type=System.Data.SqlClient.SqlException,Message=Incorrect syntax near
')'.,Source=.Net SqlClient Data
You can't directly use the pipeline parameter in Query instead need to use #concat function to concatenate your SQL Query with parameters. Please refer the example below:
I suggest you to please go through this tutorial from #TechBrothersIT to get more clarification on the related issue.

Migrating a SQL Anywhere database using triggers

I was trying to create a trigger using SQL Anywhere which would export the database so it can be transferred to another database. The query is the following:
SELECT * FROM Estudante ;
OUTPUT TO 'c:\Users\XUSERX\Desktop\file.xml'
QUOTE '"'
FORMAT XML ;
When running it shows error on the line
OUTPUT TO 'c:\Users\XUSERX\Desktop\file.xml'
The OUTPUT TO syntax is only available in the dbisql utility, not in stored procedures or triggers. Look at the UNLOAD statement in the docs.
Disclosure: I work for SAP in SQL Anywhere engineering.

Query from QSYS2.SysTables returns error "Token; void"

I am trying to read data from AS400 DB using Excel, VBA and ODBC driver. Connection is successful but none of the queries are retrieving data from DB. For ex: The select query is not working:
select * from QSYS2.SysTables;
The Client gets the following error message:
[IBM] [System i Access ODBC Driver] [DB2 for i5/OS] SQL0104 - Token; void. Valid tokens: <END Instruction>.
What is wrong with my query?
Edit: I am trying to read data from AS400 only not from DB2. I want to read the table names from SysTables(system table).
Remove the statement termination character (;) for a single statement execution.
This is an example for retrieving queries:
"Select * from Tablename";
If it doesn't work, try checking the manual for query in Microsoft. It's different from standard SQL queries.

Execute Stored Process with pass in SQL query from another table?

Currently my development environment is using SQL server express 2008 r2 and VS2010 for my project development.
My question is like this by providing a scenario:
Development goal:
I develop window services something like data mining or data warehousing using .net C#.
That meant I have a two or more database involved.
my senario is like this:
I have a database with a table call SQL_Stored inside provided with a coloum name QueryToExec.
I first idea that get on my mind is written a stored procedure and i tried to came out a stored procedure name Extract_Sources with two parameter passed in thats ID and TableName.
My first step is to select out the sql need to be execute from table SQL_Stored. I tried to get the SQL by using a simple select statement such as:
Select Download_Sql As Query From SQL_Stored
Where ID=#ID AND TableName=#TableName
Is that possible to get the result or is there another way to do so?
My Second step is to excecute the Sql that i get from SQL_Stored Table.Is possible to
to execute the query that select on the following process of this particular stored proc?
Need to create a variable to store the sql ?
Thank you,Appreciate for you all help.Please don't hesitate to voice out my error or mistake because I can learn from it. Thank you.
PS_1:I am sorry for my poor English.
PS_2:I am new to stored procedure.
LiangCk
Try this:
DECLARE #download_sql VARCHAR(MAX)
Select
#download_sql = Download_Sql
From
SQL_Stored
Where
AreaID = #AreaID
AND TableName = #TableName
EXEC (#download_sql)

TSQL SQL 2000 stored proc cursor

I'm new to this board. I have been driving myself crazy trying to find the answer to my problem.
I created some TSQL code that executes some dynamic SQL in a cursor within a stored proc. The cursor fetches some data from table x, builds a query based data retrieved in table x, runs the query, and returns data. Works like a charm.
When I add an 'insert into table' to capture the results I get an error: NOTE: only errors with SQL 2000 runs great on SQL 2008.
The operation could not be performed because the OLE DB provider 'MSDAORA' was unable to begin a distributed transaction.
OLE DB error trace [OLE/DB Provider 'MSDAORA' ITransactionJoin::JoinTransaction returned 0x8004d01b].
You should not be using a cursor for this. My guess would be a comflict with the cursor and the insert into table.
Please post code and the problem you are tyring to solve so that we can help you write it correctly.