0

Hello
I am new to this forum.

I am using MS SQL 2005 Express

I have a database GK.dbo (the original databese) and I have created a database GK_2009.dbo (it is created from the original database, so it has the same structure)
I want to create a script that would copy a table from GK database to GK_2009 database and after the copying is finished and verified, the data from the table in the GK database, must be deleted (only data, and not the table). I need it for the scheduled data copying, and I will use Windows Scheduled task. is it possible to do it? how can I do it?

regards,
vedro

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by vedro
0

Hello

I am known with those commands.
How would a script look, that could perform this action in scheduled task?

regards,
vedro

0

Hello

I have managed to write a working script:

It is a Stored Procedure script. If anyone else will need something alike:

CREATE PROCEDURE usp_BackupTableAlarmi
AS
SET XACT_ABORT ON
BEGIN TRANSACTION 
BEGIN TRY
SELECT * INTO GK_2009.dbo.Alarmi FROM GK.dbo.Alarmi
TRUNCATE table Alarmi
COMMIT TRANSACTION;
END TRY 
BEGIN CATCH 
IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION
PRINT ERROR_MESSAGE(); 
END CATCH;

Regards,
vedro

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.