SSIS not updating table after insert - sql

I have an SSIS package that sends data from SQL 2014 to an Oracle 11G DB. No issues connecting or transferring the data to Oracle but it fails when updating the source SQL tables. SSIS give ORA-00971:missing SET keyword
Based on the below why would Oracle be looking for a SET keyword? The update statement is on the SQL database
I've switch connections to reflect the SQL tables (errors resolving the Oracle table names then)
UPDATE INTERFACE.dbo.TURN
SET INTERFACE.dbo.TURN.DUPLICADO =
INTERFACE.dbo.TURN.DUPLICADO + 100
WHERE EXISTS
(SELECT
*
FROM [REMOTEORA]..[REMOTEORA].[TURN_BALANCE] BO
WHERE BO.[TURN_BALANCE].[ID_TURN]=INTERFACE.dbo.TURN.N_TURNO AND BO.
[ID_PLACES]
= INTERFACE.dbo.TURN.ID_LUGAR AND
BO.DT_CLOSE =INTERFACE.dbo.TURNO.FIN_TURNO)
AND (INTERFACE.dbo.TURN.DUPLICADO < 100)

First changing the connection for the updating piece to the SQL server resolved the ORA error but the updates were still failing and calling TURN_BALANCE a column. Altering the table alias to four letters (BOYO) vs the two (BO) completely resolved the issue

Related

Inability to run an SQL statement with a "with" statement in Excel

I am trying to run SQL through excel and I have the following SQL query within the data connection:
WITH TEST_DB as (select * from TEST_ADM.KPI_SAMPLE_TEST)
SELECT DISTINCT
BASE.YEAR_MONTH AS YEAR_MONTH
FROM TEST_DB BASE
If I try running this with SQL Developer, it will run successfully, no problems but when I try to run it in Excel, I get the message:
The query did not run, or the database table could not be opened.
Check the database server or contact your database administrator. Make sure the external database is available and hasn't been moved or reorganised, then try the operation again.
Is there some sort of limitation within Excel that prevents me from using WITH statements?
If I remove the statement and select from the table directly, it works but I need to use the WITH data table 6 times in my code and its rather long.
Oh, the database is an oracle database.

SSIS insert recrods from Oracle to SQL and even process them

Thanks for answering...
I am new to SSIS and I have below requirement:
We are getting bulk records from Oracle based on some criteria.
I need to insert all these bulk records first to an audit table in SQL server The tables has only few columns. the reason for this is we will get to know how many records in each cycle we have got from oracle and if they are pilling up what is the exact reason.
After inserting in audit table, I need to process them one by one in SQL server and at the end of processing I would be either accepting the record and inserting the entire record in SQL serever or rejecting the record in SQL server based on business condition.
Currently to implement this I have first added a Data flow task in SSIS package which selects few columns(which are required by Audit table) from the Oracle and inserts them to SQL server after conversion. Than I am again getting the records from oracle using SQL execute task and processing them one by one using for each container in sql server.
As mentioned above I am making twice the call to Oracle, I am not able to reduce this to one?
can someone please guide me how can I achieve this?
Thanks in advance.
If you have the data already in SQL (you did a bulk copy in your audit table) you can take the data from there and do the insert in the table you want.
Instead of reading the data from Oracle twice, you can use your SQL Execute Task to manipule the data in SQL. You can make the insert statement from here to the final table.

Create and copy a table from one SQL database to another

Let's say I have a production database and a development database.
The CUSTOMER_PERMISSIONS table is created and populated in the development database.
What is the best way to create and copy the CUSTOMER_PERMISSIONS table to the production database?
INSERT INTO CUSTOMER_MARKET_PERMS
SELECT * FROM indeiso.dbo.CUSTOMER_MARKET_PERMS
returns
INSERT INTO CUSTOMER_MARKET_PERMS
SELECT * FROM inukiso.dbo.CUSTOMER_MARKET_PERMS
Error at Command Line:668 Column:25
Error report:
SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:
I am using Oracle 12 database system, and i am not sure why it is throwing this error
on the prod server you can do a query like this:
INSERT INTO CUSTOMER_PERMISSIONS
SELECT * FROM [devserver].dbo.CUSTOMER_PERMISSIONS
If you're okay with not using a query, and in case you happen to be using MSSQL Server, why not use the import/export wizard?
Right-click the database you want to export from, then select TASKS -> Export Data. From there, follow the wizard.
Are you sure that you have two different Oracle databases? If so then you need to setup a database link between the two databases. If I were you I should first make sure that you from the production database can select the data in the development database. If you can that and the two tables are identical then I can't see way your statement is not working.

Strange issue between sql server 2005 (32x) and sql server 2008 (64x) linked server

I have successfully created linked server between 2005 and 2008 version. We changed a table schema on 2008 and re ordered the table columns. We also did the same on 2005 server.
If we query both table in their own database then schema looks fine however
when I do
SELECT * FROM and Select * from then it is showing me old schema for 2008 table. Due to this my join and inserts are failing. Error "insert failed due to table column mismatch"
We restarted both the machines still not luck
Any idea ?
After some research I found answer on stack overflow it self :D
Column name or number of supplied values does not match table definition
Do drop #table and then select * INTO

SQL Server 2005: problem with old SQL Server 2000 database

I attached database from SQL Server 2000 to SQL Server 2005 and it worked well but I had column called (Add Date) which had the Date time of input data and when I insert new data after attached data base to SQL Server 2005 the new data insert with same data 12.00 also it converted all old date to 12.00.
Please anyone help me how I can solved this problem also how can retrieved old Date time ?
I would start of with the obvious first
Check the columns properties to make there there isn't any default value being applied
Change the database compatablity level to make sure its set to SQL Server 2005 (90) (Right click on database Properties > Options Tab)
EDIT:
If you wanting to formated what date gets inserted into the (Add Date) field you can use the CONVERT or CAST function.
solution 1:
attach old database again, named it "old_bak"
and then write t-sql like this:
UPDATE XX
SET col = T.col
WHERE
XX.id = old_bak.dbo.XX.id
then the old data will retrieved!
solution 2:
rollback your database from .bak file
and execute your sql statement again
I doubt that your sql statement is "update", not "insert". or it won't be like that.