I created an SSIS file to add a table to a sql database from a spreadsheet. I can execute the file 1x and it works. But when I delete the table and try to recreate it by executing the SSIS file again, it gives me an error that the table already exists. But it is deleted. Does anyone know what I might be doing wrong?
Related
I have a SSIS package that imports a flat file into a table within a db then moves on to next data flow task. This works as expected.
After the initial loading file into db I want to check to see if the file name has changed.
If it has, delete the content of db table and re import flat file.
If it hasn't don't do anything and move onto next task.
Any advice around how to achieve this would be greatly appreciated
Update
What I thought I could do is to check a location.
If the file exists then delete content from db table and import file into DB table. Then delete the file.
If the file doesn't exist then don't import/don't delete file and don't delete the db table. Simply move onto next task.
Is there a tool that I can use to check if file exists? Is my solution achievable?
I have two different scripts, one created by me and one by my collegue, that is using the same snapshots.
16.00 (or 4 PM) Coded by me.
Script 1 - deletes snapshots if they are there, creates new snapshots - executes code.
04.00 (or 4 AM) Coded by Collegue
Script 2 - deletes snapshots if they are there, creates new snapshots - executes code.
Both of these scripts are SSIS scripts that are just holders for Stored Procedures (the SSIS scripts actually don't do much more than executes a bunch of Stored Procedures in a chain).
Script 2 works without problem.
Script 1 get's 'snapshot cannot be deleted, you don't have access or the snapshot is not present in the database'
If I run script 1 in SQL Studio it works perfectly so I have not spelled anything incorrectly.
Both scrips are running under the same user both in the SSIS engine and in the JOBS engine.
I don't even know where I should start looking for errors for this?? Any suggestions?
------------- Edit: Script added ----------------
IF EXISTS(select NULL from sys.databases where name='Citybase_Snapshot')
BEGIN
DROP DATABASE Citybase_Snapshot;
END
CREATE DATABASE CityBase_Snapshot ON
( NAME = FastighetsBok_Data, FILENAME = 'S:\Snapshots\Citybase_Snapshot.ss' )
AS SNAPSHOT OF Citybase;
---------------- Edit: Error message added ----------------------
As far as I know this is a normal error message from SQL server.
EXEC proc_..." failed with the following error: "Cannot drop the
database 'Citybase_Snapshot', because it does not exist or you do not
have permission.".
The answer was more simple than I imagined.
You set an active user on the SSIS script that's running when you create a job in the SQL server for the SSIS job, but that's not the only place you might have a security user on.
You also need to check the connection you actually establish inside the SSIS script to make sure that the user that you use to connect to the database is allowed to drop the snapshot.
Easy as pie (when you know what's wrong).
Hi I have looked for ways to do this but cant seem to get a clear answer. We have a requirement to Dump any changes to a table in SQL to a CSV File i.e Whenever anyone makes a change on the frontend to a customer record it must dump those changes to a CSV file for us to Update another System. Can anyone help me with an example either using SSIS or SQL Triggers.
I am new to SQL.
What is the best way to create a TXT file, if a table has records > 0?
The code already exists to remove or add records to this table.
I am looking for ways to create a trigger file (with no content in the file) at a specific network folder.
Preferably, I would want this TXT file to be removed at the end of the day, so the process could repeat itself every morning
On an after delete Trigger do a select count(*) from table or query one of the system catalog views. If its zero, then call a stored proc that poops a file onto your share drive.
To move the file you could create a small package or call a powershell or bcp (after enabling xp_cmdshell though), or you could create a CLR function (after enabling CLR). I guess since the latter two you need to change a server setting, you could just create a package.
Annnd since there is no data you dont actually need to export, you just create a blank file!
i have a strange problem with the creation of the external table.
I have an external table "X" under the user X. If i try to create another External Table by doing the copy and paste of sql code, i have this error when i do SELECT * FROM x
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
ORA-29400: data cartridge error
KUP-04040: file CFO_PC.csv in EPM_SERVICE_DATA not found
ORA-06512: at "SYS.ORACLE_LOADER", line 19
the EPM_SERVICE_DATA is the directory where is the file CFO_PC.csv
My user have the grand read and write on this directory.
have you no idea what the problem is?
Sorry for my english...
Is it the same file? CFO_PC.csv Then it should be locked by the original external table.
Copy it, and create a new external table using the copy (make sure that Operating System write/read privileges are correct for the Oracle Database group.
I have resolved, i have copied the sql code from sql developer and it added the code that, it even plays.
LOCATION ( 'CFO_PC.csv' ) is correct
LOCATION ( EPM_SERVICE_DATA: 'CFO_PC.csv' ) not correct