Trigger For SQL Server 7 To Copy Data

Feb 7, 2003

When a user deletes a row from table "A", I would like to copy that row to table "B", so I can restore it if I need to.
TIA

View 7 Replies


ADVERTISEMENT

How Do I Get A Trigger Just To Copy The Inserted Row.

Feb 8, 2005

HI I have a trigger which I want to copy any rows in the MSmerge_history into a archieve table. I am using this trigger:

CREATE TRIGGER History_replication ON
[dbo].[MSmerge_history]
FOR INSERT
AS
INSERT [dbo].[MSmerge_history_archive]
(
agent_id,
runstatus,
start_time,
[time],
duration,
comments,
delivery_time,
delivery_rate,
publisher_insertcount,
publisher_updatecount,
publisher_deletecount,
publisher_conflictcount,
subscriber_insertcount,
subscriber_updatecount,
subscriber_deletecount,
subscriber_conflictcount,
error_id,
[timestamp] ,
updateable_row
)
SELECT
agent_id,
runstatus,
start_time,
[time] ,
duration,
comments,
delivery_time,
delivery_rate,
publisher_insertcount,
publisher_updatecount,
publisher_deletecount,
publisher_conflictcount,
subscriber_insertcount,
subscriber_updatecount,
subscriber_deletecount,
subscriber_conflictcount,
error_id,
[timestamp],



How this copy the entire contence of the table into the archive each time someone insert a row. How do I get it to only insert the row which had triggered the insert? Ed

View 2 Replies View Related

Copy Data To SQL Server By Checking (available)

Oct 1, 2001

Hello,

I connect from SQL Server on Windows 2000 to Progress
Database on UNIX.
The database name of SQL Server is cstarsql and the
name is cstarint on UNIX.

I would like to schedule to copy data from
cstarint(Progress) to cstarsql(SQLServer). I did for
one time, but I want to control if the data has
already copied or not. If not, it will copy.

In DTS Query Builder to copy from Progress to SQL
Server,
SELECT * from calls WHERE call_date = TODAY
The name of table of calls is the same for both
database.The above calls is cstarint(Progress
Database)
This command is enough for one time. But I need to
control if the record has already copied.


In SQL Server, I control if the record is available or
not with @@FETCH_STATUS .
Now I would like to mix two queries, but I couldn't.
Can anybody do this?

DECLARE calls_cursor SCROLL CURSOR
FOR SELECT * FROM calls
WHERE call_date = TODAY

OPEN calls_cursor

-- Perform the first fetch.
FETCH NEXT FROM calls_cursor

-- Check @@FETCH_STATUS to see if there are any more
rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN
-- This is executed as long as the previous fetch
succeeds.
FETCH NEXT FROM calls_cursor
END

CLOSE calls_cursor
DEALLOCATE calls_cursor

Alice

View 1 Replies View Related

Sql Server Failed To Copy The Data

Aug 18, 2004

Hi,
I am trying to copy the data and tables from My server(SqlServer2000) to another Server(MSDE2000A) using DTS, after some time i am getting an Error " the login PDD Doc handler doesnot exist" failed to copy the data. How to fix this, appreciate your help
Thank You

View 1 Replies View Related

Copy SQL Data Structures From One Server To Another

Oct 17, 2007

Hello,
I have a sql database server (let call it server A) which has SQL program files installed on C:, and SQL data structures MSSQL (include subdirectories BAckup, DATA, FTDAT, JOBS, LOG, REPLDATA) on F:. A new server (call it server B) was cloned of server A but only at the C: partition. I still need to manually copy the SQL data structure on F: drive from A to B. The purpose of setting up server B is to test the restore of backup of server A and eventually want it to serve as the standby server should server A crashes. My questions are
1. Can MSSQL directory be copied from A to B without stopping the SQL server service on A first?
2. I will use robocopy for copying data over, what switches should I use to retain all database file security, permission, etc..
3. Currently I can not start the SQL service on server B because part of MSSQL directory is missing from the F: drive. so theorically, after I manually copy that folder over, I should be able to start the sql service. Am I right? Is there any steps that I might have overlook here. Any errors I might encounter doing it this way

Once I can get the sql started, I can take care of the restore part.
Thanks for any insights or suggestions you can provide on this.


View 7 Replies View Related

Copy Data From SQL Server To SQL Mobile

Jan 8, 2007

Hello

I'm developing an application that need to create everyday information to be stored in a SQL Mobile Database.

The SQL Mobile database will have:

Last schema from tables (in SQL Server database);
Last information in the tables;

I don't want to copy all the tables from SQL Server database than this mecanism should give me the way to choose the tables.

I have been reading about the SqlCeReplication but I don't undestand what is InternetUrl property. The SQL Mobile database is created in the PC and after is copy to the the Mobile Device.
How can I avoid the InternetURL property?

tkx in advance
Paulo Aboim Pinto
Odivelas - Portugal

View 1 Replies View Related

SQL Server Data Copy Problem

Apr 14, 2007

Hi,



I am facing a great problem. I have a DB about 80GB. There are 217489811 number of records which include 2005, 2006 and 2007 data in 1 table. Now I want to split the table into by quarter tables 2005Q1, 2005Q2.....etc. It is because it is easier for me to housekeep the old data. (It takes about few hours to housekeep 3 month data currently, so that it affect my server performance a lot)



so I start my work, however it is failed every times. Actually, if I copy 3 month data to a new tables, it is nearly about 30 million records which needs about 1 GB space. However, it takes about 8 hours to complete the job and failed because of not enough space allocated. Actually, my Server has about 50GB space, but when the job complete and fail, all the space is occupied. But i wonder why this happen because the data only need about 1 GB, how come it use 50GB?



it seems that nothing i can do to housekeep the old data. because housekeep the current table takes too long time while splitting tables use up all the space. So how can i do?



For your information, the table has non-clustered index on the data date field



need your help

thanks,

Linus

View 2 Replies View Related

SQL Server 2014 :: How To Copy Data Rows From Hosting To Local Server

Mar 11, 2015

I'm a web developer who writes transact-SQL to make my web applications run properly. I'm not real strong in other areas of SQL. Let me explain our set-up and then I'll explain what I want to do:

We have an ecommerce web site and all sales are saved in a SQL Server 2008 R2 database at our hosting company. We also have a local Windows 2012 network that has SQL Server 2014 Express installed.

Here is what I want to do:

I want to copy sales rows from the SQL Server 2008 database at our hosting company and save them in the SQL Server 2014 Express database on our local Windows 2012 server. I'd like to automate this if possible so that it happens each night perhaps. I know there is a way to schedule SQL jobs but I've never actually done this. I also would need to know how to attach to our hosting company DB as well as our local network DB.

View 2 Replies View Related

Copy Data In Sql Server Table A To B On Same Server - Identical Schemas

Dec 13, 2006

Greetings,

I have two SQL Server tables on the same server and in the same database. I'll call them table A and table B. They have identical schemas. I need to insert all rows in table A into table B. (Don't laugh - this is just for testing and long run the tables will reside on different servers.)

Can someone please tell me the correct task to use for this and the connection type I need for both the source and destination?

Thanks,

Black Cat Bone

View 9 Replies View Related

Copy Objects And Data Between SQL Server Databases

Jun 3, 2001

Copy objects and data between SQL Server databases
"
Display the Select Objects to Transfer dialog box, where you can specify both objects and data to copy, if both the data source and destination are Microsoft® SQL Server™ databases. The objects you can transfer include tables, views, stored procedures, defaults, rules, constraints, user-defined data types, logins, users, roles, and indexes. You can transfer objects only between multiple instances of SQL Server version 7.0, from an instance of SQL Server 7.0 to an instance of SQL Server 2000, and between multiple instances of SQL Server 2000.
"


can I apply "Copy objects and data between SQL Server databases"
to run in two different sqlserver 2000 ( not an instance ) . what I mean is I have two different sql servers located in two different locations( I am not using an instance installation) can I still run the copy and get an identical database in both servers.
Q2. if I have two sql server 2000 with different collations (one is binary and the other is the default) will I be able to run the copy wizard and still have an identical copy of sql server in both servers.

I personally tried to run the copy wizard and IT NEVER WORKED FOR ME and I really do not know the reason.

Thanks for your input.

ali

View 2 Replies View Related

Getiing A Copy Of Data Bse From A Remote Server

Jun 18, 2007

I am an authenticated user of a remote data base

I can log in and add tables and even I can back up the database .

Good.



But I want to get a copy of the database to my local computer

Is there any way to do this?





_sujithsql_

View 5 Replies View Related

[SQL SERVER 2005] Copy Data From One Database To Another On Same Server

Mar 29, 2007

Ok, here is my dilemma
I have an application that has many sites. Each site has it's own database. The databases have common tables (ie the name and fields are the same) What I want to be able to do is when creating a new database, I want to be able to copy certain common table data from one database to another. I have run into an error because the table have an IDENTITY so this is not working

INSERT INTO Containers SELECT * FROM ADMS2_Indian_Point.dbo.Containers

I also tried
USE ADMS2_RSCS
GO
SET IDENTITY_INSERT Containers ON
GO
INSERT INTO Containers SELECT * FROM ADMS2_Indian_Point.dbo.Containers
GO
SET IDENTITY_INSERT Containers OFF
GO

I got an error saying that I need to have a column list. I am trying to use this for any tables, so my question is this..
Is there any way to get around using a column list or is there a way to dynamically create the column list?
Or, Is there a better way that I should be doing this?

Please keep in mind I am not a dba and everything I have learned about SQL is from my good pal Google :)

Thanks for any help

View 3 Replies View Related

Copy Data From SQL Server Compact To SQL Server 2005

Oct 4, 2007

Is there a way to use SSIS to copy data from a SQLServer CE database to a SQL Server 2005 database?

I have a database that has only been used on a mobile device, but now I want to use it among several devices, so I want to copy the structure and data to a SQL Server 2005 database and expand it's scope.

View 3 Replies View Related

How To Copy The Data From One Server To Another Server Using Sql 2000 DTS Packages

Nov 12, 2007

I am trying to copy/update a table which is in server2 based on a similar table which is in server 1. I can't use replication,
so I am thinking which are the best ways to do without affecting the performance as the source table is busy with inserts or updates. I am thinking of following options:
1. SQL server 2000 DTS packages: As I am trying to copy the data from the source table(server1) into a destination table which is a similar table in server2, if I use dts first I want to take the complete snapshot and then on I only want to copy the new transactions or updated transactions, please let me know how I can do this.
2. Does trigger affect the performance as the server1(source table) is a busy server.
Please let me know. Thanks.

View 12 Replies View Related

Copy Data From 1 Table To Other In Stored Procedure In Sql Server

Apr 15, 2004

Hi there,

Can u please tell me how to copy data from table A(database A) to table B(databaseB) which table A contain 10 fields but table B consist of 11 fields. I have to insert current date and time into another field in Table B (which has extra field compare to tableA) automatically every hour or so.
Please help.
Thanx

View 2 Replies View Related

SQL 2012 :: How To Copy Data From One Table On Remote Server A To B

Aug 12, 2015

how to copy a content of a table from one remote server to another,. server A does not see server B (B doesn't see A) - I cannot even ping to one from another.I do have SQL Studio installed on server C, which IT team configured to allow access to both A and B.So what I did so far is to periodically:

1. connect from the studio on server C to server A
2. run the following script on server A: SELECT * FROM A.myTable FOR XML PATH('ROOT')
3. copy the result
4. connect from the studio on server C to server B
5. to write something like

DECLARE @xmlData XML;
SET @xmlData = pasting here my result from item 3 above

6. INSERT INTO
SELECT

ref.value .....
FROM @xmlData.nodes('/myElemnet/ROOT')
xmlData( ref );

so it works. now there is a requirement to schedule this update to run periodically and I need to implement it..

View 9 Replies View Related

Missing Data Flow Items After Copy Into The New Sql Server

Feb 20, 2008

Hi... Please help. I am having problem with my hard drive so I git a new one. I installed a new instance of SQL Server 2005 and copy over all my projects from the old hard drive into the new.

The problem is, when I open my packages specifically the data flow task it is empty. All my dataflow items are gone.

I am not sure what I am missing during the copy. Please help how I can recover my complete packages.

Thanks a lot!

Concon

View 15 Replies View Related

Copy Data To Excel File Using Dts Package In Sql Server 2000

Jul 26, 2007

Friends

Any one of you share your knowledge how to transfer data from a database to a excel using dts packages in sqlserver 2000.

I want clear steps how to create a dts package

Appreciate your help

Thanks
satish

View 1 Replies View Related

How Do I Copy The Index Statistics To A Development Database Server Without Data.

Jul 16, 2007



I want to be able to reproduce my production execution plans on development with copying data.

View 1 Replies View Related

Using Trigger To Insert Data To Different Server Database

Sep 25, 2007

i have 2 server named A and B

in A server have database server and B have database server

in A have database named A1 with table TA1 and in B have database named B1 with table TB1

i want if i insert data into database A1 table TA1 in server A, database B1 table TB1 in server B will insert the same data to

how can do that with trigger or other ways

thx u

View 2 Replies View Related

SQL Server 2008 :: Add A Trigger That Inserts Original Data From 1 Table To Another

Apr 10, 2015

I am trying to create a trigger on a table. Let's call it table ABC. Table looks like this:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ABC](
[id] [uniqueidentifier] NOT NULL,

[Code] ....

When someone updates a row on table ABC, I want to insert the original values along with the current date and time getdate() into table ABCD with the current date and time into the updateDate field as defined below:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ABCD](
[id] [uniqueidentifier] NOT NULL,

[Code] .....

The trigger I've currently written looks like this:

/****** Object: Trigger [dbo].[ABC_trigger] Script Date: 4/10/2015 1:32:33 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER [dbo].[ABC_trigger] ON [dbo].[ABC]

[Code] ...

This trigger works, but it inserts all of the rows every time. My question is how can I get the trigger to just insert the last row updated?

I can't sort by uniqueidentifier in descending as those can be random.

View 9 Replies View Related

SQL Server 2012 :: In Trigger - Building Dynamic Table With Inserted Data

Nov 4, 2015

Within a trigger, I'm trying to create a unique table name (using the NEWID()) which I can store the data that is found in the inserted and deleted tables.

Declare @NewID varchar(50) = Replace(convert(Varchar(50),NEWID()),'-','')
Declare @SQLStr varchar(8000)

Set @SQLStr= 'Select * into [TMPIns' + @newID + '] from inserted'
Exec (@SQLStr)

I get the following error: Invalid object name 'inserted'

I know I can do:

Select * into #inserted from inserted
Set @SQLStr= 'Select * into [TMPIns' + @newID + '] from #inserted'
Exec (@SQLStr)

But I don't want to use TempDB as these tables can become big and I also feel that it is redundant. Is there a way to avoid the creation of #inserted?

View 2 Replies View Related

How To Copy Data From Backup Or Data Files To New SQL Installation?

Dec 10, 2005

Hi,I have(had) an old Win2k Server server with about 30 web site databases(SQL 2000) that just went under due to hardware problems. Thankfully, Ihave backups of all the databases plus the MDF and LDF files from thehard drive.I want to move all of these sites and their data to a newer server(Win2003) running SQL2000.What's the best way to copy the database from the old server hard drive(now mounted as an extrnal drive to a local machine; I'm currentlyFTPing all of the web site directories from it to the new server)?Just upload the original data to the new server and then mount the MDFand LDF files within the new SQL server? Or do I restore the backupfiles in the new SQL2000?All of my previous data migrations have been DTS operations from onelive server to another, so no experience with either of the abovescenarios. I'll certainly have a lot more experience at one of them bythe time this weekend is through.Thanks for any help you can offer.

View 1 Replies View Related

Bulk Copy XML Data To SQL Data Source

Aug 12, 2006

Can anyone provide an expample of bulk copying XML data to a SQL table. I am also looking at using column mapping so that I can map fields and also insert a new GUID into the key of the SQL table.
Many thanks

View 1 Replies View Related

Trigger Not Execute Some Data Or Insert Not Execute A Trigger For Some Data

Mar 3, 2008

I have trigger, but not execute somedata because insert few row in every second. I use java to insert data to SQL server 2005. Data inserted to a table but not executing trigger for some data.
For example 100 data every second inserted to a table.

If insert data one by one to a table trigger fires success.
Please Help me.

View 1 Replies View Related

Copy Data From 1 Tbl To Another Tbl

Dec 5, 2005

i have a claims_tbl that i am inserting into with claim information, the tbl contains a claim_seq number that i want  to copy over to a  user_info_tbl at the same time insert user information below is what i have tried with no luck
insert into user_info(claim_seq) select Max(claim_seq) from claim_tbl 
update user_info  set  lname =upper(@lname), fname =upper(@fname), mname =upper(@mname), personnel = @personnel, p_position =upper(@position)where claim_seq = (Select Max(claim_seq) from user_info)
i am getting duplicate rows of information ..........can someone help
 
thanks
 
 

View 2 Replies View Related

Copy Data

Jul 25, 2001

Hi!
What is the best way to copy data from SQL server to Access database located on differet machines?
Thank you,
Elena.

View 1 Replies View Related

Copy Data From One Db To An Other Db

Sep 11, 2006

Hello,

there is a database with an table x and I want a copy of that in my testdatabase.

I am pretty sure, that I have done that the whole last week, but it's not working anymore.

I thinkt, that last time I used a statement like that to copy the table with structure and all.

insert into dbtest.dbo.x select * from db.dbo.x

Today it's only telling me, that the destinationtabel x is not present.
The table has about 100 fields and I swear, I didnt create it by hand in the testdatabase, I'm definitely too lazy for that.
I can't use the enterprise manager, I only can use sql.

There are still tables in my testdatabase, I copied last week. So what is wrong with my insert into?

View 1 Replies View Related

Copy Db W/o Data

Apr 7, 2008

All,
Does anyone have amethod for copying db(all tables, procs etc..) but without the data. Scripting is not feasible because of number of objects constraints ..etc...

any help would be appreciated
thanks,
JB

View 6 Replies View Related

How To Copy Data From One....

May 26, 2008

hi

How to copy data from one column(field) to another column(field).

I have two column colA & ColB
Both column have data.

but i want to replace all ColB data with ColA.

it is like this,
COLA COLB
abcd grfr
dfere kieidk
fere fkerie

but, I want like this
COLA COLB
abcd abcd
dfere dfere
fere fere

please help me

View 2 Replies View Related

Cant Copy Data From One DB To Another.

Oct 6, 2005

I am trying to copy item names from one database to another if they share the same code number.
e.g.

UPDATE TABLE1
SET NAME = DB2.TABLE2.NAME
WHERE CODE = DB2.TABLE2.CODE

I dont know how to specify the second db as using a '.' here doesnt seem to work. I have also tried '..' and DB2.dbo.TABLE2 but get the same error - 'The column prefix 'Train_DB_FinancialsProd.dbo.ITEM_DEFINITIONS' does not match with a table name or alias name used in the query.'

I have checked that the spelling is ok so not sure why it doesnt work.


I have also tried using a temp db in between to copy the values across then try to update from the temp table but couldnt make that work either. e.g.

create table #tdhname
(
code char(50),
name char(100)
)


INSERT INTO #tdhname (code,name)
select distinct code,name from Train_DB_FinancialsProd..item_definitions tritm
where code = tritm.code
and tritm.ittyp_refno = 241

update pharmacy_items
set name = #tdhname.name <----- THIS DOESNT WORK
where #tdhname.code = code



Thanks!

View 5 Replies View Related

How Can I Copy Data

Jul 23, 2005

hi their,How can i copy data in MS-SQL 2000 from one table to another withdifferent charactristic?thanks*** Sent via Developersdex http://www.developersdex.com ***

View 3 Replies View Related

Data Copy

Mar 10, 2008

Help!!! I am trying to consolidate 5000 odd databases. Each database contains hundreds of tables. The tables in each database are identical to the tables in all of the other databases. Sounds simple doesn't it? However, SSIS has defied every trick that I have applied to this task including changing connectionstrings at run time through package configuration. has anyone out there ever tackled a similar challenge?. Please let me know

Desperate

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved