Moving multiple table data from one database to another database by stored procedure using SSIS packages - sql

I have a stored procedure which gets data from table trans of database "A" and inserts into multiple tables (trans, trans_log, trans_history) in database "B" and then this procedure just deletes that data from the trans table in database "A". This is just an archive process. The procedure RETURNs 0 if successful.
Previously it was scheduled as a SQL job, but now I need to create an SSIS package for it. How to create SSIS package for this? I know that I need to create source and destination connection in a dataflow, but I am stuck at mapping columns, my procedure does not any return columns it just inserts into multiple table of another database.
How do I define source and destination or how do I perform this in SSIS package?

Related

SSIS schema switching deadlocks

I have an SSIS package which takes data that has changed in the last 1/2 hour and transfers it from a DB2 database into a SQL server. This data is loaded into an empty import table (import.tablename) then inserted into a staging table (newlive.tablename). The staging table is then schema switched with the live (dbo) table within a transaction. FYI, the dbo tables are the backend to a visualization tool (Looker)
My problem is that the schema switching is now creating deadlocks. Everytime I run the package, it affects different tables. I've been using this process with larger tables before (also backend to Looker) and have not had this problem before.
I read in another post that the user was having a similar problem because of indexes but all the data has been written to the destination tables.
Any ideas or suggestion of where to look would be much appreciated
The schema switching code is within a Execute SQL Task in the SSIS Package with:
BEGIN TRAN
ALTER SCHEMA LAST_LIVE TRANSFER DBO.TABLENAME
ALTER SCHEMA DBO TRANSFER NEW_LIVE.TABLENAME
GRANT SELECT ON DBO.TABLENAME TO LOOKER_LOOKUP
COMMIT TRAN

Copy and rename the Stored Procedure by using SQL server query

Greetings for the day!!
My requirement is we have Stored procedures created with one ID in database now i need to copy the script of Stored procedure created with existing ID and rename it with New ID.
Is there any SQL server Query to do above process.
PS:i am aware about sp_helptext. looking for SQL script.
Thank you.

Referencing a dynamically created table in SSIS "source assistance"

I have an SSIS project that does the following:
Executes a sql task (in the control flow) that creates (and populates with data) 4 tables. After that executes I have a Data Flow task that references those 4 tables, joins them, then uses the destination assistant to create a new table called "Step". Then, those 4 tables are deleted leaving only the "Step" table.
However, when I try to run it it throws an error because technically I am referencing 4 tables that do not yet exist. How do I work around this?
I would do this the same way you have to handle temp tables in a data flow source.
Use a stored procedure for your datasource, and start it with something like:
IF 1=0
SELECT
{dummy-valued column list that matches the column names and datatypes of your expected output}
ELSE
{your real stored procedure code}

using stored procedure to connect to db in external server

I have a stored procedure that updates a table taking the data from a source and I want to modify the stored procedure so that it takes data from a table in an external database and updates a table in the original server. Can this be achieved and how ?
See linked servers, it's treated just a synonym: http://msdn.microsoft.com/en-us/library/ff772782.aspx
Actually synonyms are treated like linked servers..

How To Get 'Create Table' script for a table or sp using vb6 with sql server 2000

I need the "create table... " statement for a particular table and stored procedure to recreate them in another database. Forget the backup and restore. I have to do it in vb6. Its the same thing you get when you copy the Table And paste it in query analyzer. Its sql server 2000
Edit: Now I Know it can be asked as 'How To Script Entire Database Through VB6'.
Take a look at this StackOverlow post which talks about the same. Although it is not VB6-specific, you should be able to apply this solution without a problem.
Essentially you create a stored procedure that will generate the CREATE TABLE statement for the given table. The stored procedure will examine the sysobjects table to build the SQL.
Your VB6 application can run the stored procedure on server 'A' fetching the CREATE TABLE SQL. Then connect to server 'B' and run that SQL to create the table on the other server.