Replicate (Duplicate) A Row's Data Into Same Table

Apr 20, 2008

 I'm working on a web app that needs to be able to take a row in the database and duplicate it, creating a new row in the same table with the same data except for the ID field and reference field.
So basically: table1.row1 references table2.row1. I need to duplicate the data in table1.row1 (creating table1.row2) with the same reference to table2.row1.
Is there any easy way to do this in SQL? I'm just looking for some ideas or a framework to accomplish this.
 

View 1 Replies


ADVERTISEMENT

How To Pull Data Or Replicate A Table From One Server To Another

Aug 21, 2015

pulling data from a table in Server A and creating the same table on Server B.

From what I've read you can't export/import or use a wizard as the db is of the type dbo.md_*****.

View 3 Replies View Related

Replicate Schema/Replicate Data Only

Sep 7, 1999

Using SQL 7.0 I'd like to replicate just schema from DB on server A to DB on server B, then be able to replicate data only form DB on server B to DB on server A. I need help!!

Thanks for ANY information you can give me...
~Jepadria

View 2 Replies View Related

How To Move Duplicate Data Into Other Table

Dec 10, 2013

We need to move duplicate data from this sheet to other table also having issue that sometime verifiedmemberID is null as well as verifiermember name is null and also having the values in BCP authorisationcode as well as FPoveridecode but transactionmode/bcpmode is 'n' and also having condition that transactionmode/bcpmode is 'y' but bcpauthorisationcode is blank.

MemberStatecodeMemberDistrictCodeURNCompanyCodeHeadMemberIDHeadMemberNamePatientID
PatientNamePatientGenderPatientAgeTerminalIDHospitalCodeRegistrationNoBlockingUserDateUnblocking
InvoiceNoDischargeInvoiceNoDischargeDescDischargeUserDateAmoutClaimedTransactionMode/BCPMode
UnspecifiedAuthCodeUnspecifiedAuthDateBCPAuthorizationCodeBCPAuthorizationDateFPOverideCode

[code]....

View 2 Replies View Related

Duplicate Data On One Of Fact Table

Sep 16, 2014

I have heard from my client that they are facing duplicate data issue on one of the fact table.

Basically there is a view built on fact table and client access the data through the views.

There warehouse is loaded daily through SSIS packages. The duplicate records issue is only when the views are queried during the data loading process. The duplicates are gone when the data load is completed.

View 1 Replies View Related

Query To Filter Duplicate Data From Table.

Apr 8, 2004

i am having 3000 records in table. now i want take out the duplicate from that table.

for example: i want to find out the duplicates of 'CompanyNames'.

help needed to write query for this operation.

View 2 Replies View Related

Duplicate Data In Table For Specific Columns

Nov 27, 2015

I have an table with duplicate data. I need to delete the duplicate records based on the RequestId.

I want to delete the records based on the RequestID 1001, Delete the duplicates in 1002, 1003 .

DECLARE @table TABLE ([Employee_SID] [int] NOT NULL,
[CalculatedTotalSalesYear] [numeric](19, 2) NULL,
[CalculatedTotalSalesYearAnnualized] [numeric](19, 2) NULL,
[RequestID] [int] NOT NULL)

[Code] ....

Expected Result

select * from @table

View 4 Replies View Related

Transact SQL :: Insert Duplicate Data From One Table To Another

May 14, 2015

i am having three tables

test
testId  testName  totalQuestion

Questions

QuestionId  fktestId  QuestionName

Now i am trying to insert a duplicate copy test by passing testId..Here is my sp

if not EXISTS(SELECT testName from tblTest WHERE UPPER(@testName) = UPPER(@testName))
BEGIN
INSERT INTO tblTest SELECT @userId, testName,duration,totalQuestion,termsCondition,0,GETUTCDATE(),GETUTCDATE() from tblTest WHERE id=@testId
SET @insertedTestId=@@identity
INSERT INTO tblTestQuestion SELECT @insertedTestId,question,0,GETUTCDATE(),GETUTCDATE() from tblTestQuestion WHERE testId=@testId
END

how to insert in answer table as one question can be multiple answers.

View 4 Replies View Related

SQL Server 2008 :: Getting Duplicate Data When Connecting To Another Table

Jul 25, 2015

I have the following two tables:

CREATE TABLE [MailBox].[Message](
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[SenderId] [bigint] NOT NULL,
[Message] [nvarchar](max) NOT NULL,
[SentDate] [datetime] NOT NULL,
CONSTRAINT [PK_MailBox.Message] PRIMARY KEY CLUSTERED

[Code] ....

I'm building a messaging functionality in to my application, I'm able to insert a message into the database and this message then appears inside the other users inbox. The issue I have it when I click on this message to view the conversation I make a call to the following sp as shown here:

@UserId bigint,
@SenderId bigint
AS
BEGIN
SET NOCOUNT ON;

[Code] .....

The problem with this is I'm trying to connect to the user photos table to return their profile picture, but for some reason even though I have specified IsProfilePic I get all the photos returned, instead it should be two photos, one for the @UserId and the other for the @SenderId, its equivalent to me doing this:

Select *
From [User].[User_Photos]
where (UserId = 1 or UserId = 2) and IsProfilePic = 1

And this returns me the correct information.

View 3 Replies View Related

CREATE TABLE DUPLICATE OBJECT/DUPLICATE FIELD NAME ERROR Msg 2714

Oct 2, 2007

Hello Everyone:

I am using the Import/Export wizard to import data from an ODBC data source. This can only be done from a query to specify the data to transfer.

When I try to create the tables, for the query, I am getting the following error:




Msg 2714, Level 16, State 4, Line 12

There is already an object named 'UserID' in the database.

Msg 1750, Level 16, State 0, Line 12

Could not create constraint. See previous errors.


I have duplicated this error with the following script:


USE [testing]

IF OBJECT_ID ('[testing].[dbo].[users1]', 'U') IS NOT NULL

DROP TABLE [testing].[dbo].[users1]

CREATE TABLE [testing].[dbo].[users1] (

[UserID] bigint NOT NULL,

[Name] nvarchar(25) NULL,

CONSTRAINT [UserID] PRIMARY KEY (UserID)

)

IF OBJECT_ID ('[testing].[dbo].[users2]', 'U') IS NOT NULL

DROP TABLE [testing].[dbo].[users2]

CREATE TABLE [testing].[dbo].[users2] (

[UserID] bigint NOT NULL,

[Name] nvarchar(25) NULL,

CONSTRAINT [UserID] PRIMARY KEY (UserID)

)

IF OBJECT_ID ('[testing].[dbo].[users3]', 'U') IS NOT NULL

DROP TABLE [testing].[dbo].[users3]

CREATE TABLE [testing].[dbo].[users3] (

[UserID] bigint NOT NULL,

[Name] nvarchar(25) NULL,

CONSTRAINT [UserID] PRIMARY KEY (UserID)

)



I have searched the "2714 duplicate error msg," but have found references to duplicate table names, rather than multiple field names or column name duplicate errors, within a database.

I think that the schema is only allowing a single UserID primary key.

How do I fix this?

TIA

View 4 Replies View Related

Dynamiclly Remove Duplicate Rows From Results Table Based On Column Data?

Nov 30, 2007



I have a results table that was created from many different sources in SSIS. I have done calculations and created derived columns in it. I am trying to figure out if there is a way to remove duplicate rows from this table without first writing it to a temp sql table and then parsing through it to remove them.

each row has a like key in a column - I would like to remove like rows keeping specific columns in the resulting row based on the data in this key field.

Ideas?
Thanks,
Ad.

View 7 Replies View Related

Replicate With New Table

Jan 30, 2007

Hi all, I have done the replication its working good.Now i have created the new table in publisher. but i have created the same table in sub scription too. how can i replcate this new table..?


Thanks
Krishna

View 3 Replies View Related

What Is The Best Way To Replicate Data?

Oct 18, 2006

Hi everyone, I've recently been thrown into a DBA role (I've never done any DBA work except writing a few SQL queries), so please go easy on me if these are stupid questions. My first task is to find the best way to replicate data between two SQL Server production databases. The data is to come from Production DB #1 to Production DB #2 (for access by a different system). The data has to be super-close -- not necessarily real-time, but within a few minutes. So when data is updated in #1, #2 shouldn't be be lagged by more than 45 minutes (5-10 is ideal). There are hundreds of thousands of records.What would be the best way to do this? Are there options in SQL Server 2005 to do "differential" updates from DB1 to DB2? Or is that how "transactional replication" works?  If we were to implement a "full recovery model", will this impact any sort of replication? Thanks.  

View 2 Replies View Related

What Is The Best Way To Replicate The Data?

Nov 15, 1999

Hi, there
I have a situation here....
I have Production DB and Development DB in the same SQL7.0 box....
I want to update the data and SP from Pro. to Dev at least once a day...
So this is my plan.

1. Back up(Pro.) and restore(Dev.) so I can have the same DB in the same box.
2. Using a Replication (Pulication and Subscription) ro update the data and SP.
3. Because DTS can not update the SP, I use the replication instead of DTS.
I need to update the SP, too..(Front end is ACCESS and backend is SQL7.0 DB)

Is there any other methods or way to make ti happen... Any suggestion can help...

Thanks in advance

Jay

View 2 Replies View Related

How Do I Replicate A Table In The Same Database

Sep 5, 2004

i want to replicate the data from one table into another table in the same database,all the transactions in table "a" should be replicated in table "b" and vice versa.
Note:this should be done without using triggers

View 10 Replies View Related

How To Replicate A Creation's Table

Mar 2, 2007

Hi,

i'v send this email to understand how i can replicate a creation's table between two sql servers ?

the documentation of the replication explain the replication use the alter table !!

it's possible to detect with a query this creation of table and start after the replication ?

another solution ?

Regard's





View 1 Replies View Related

NOT Replicate Data Archive

Jun 5, 2002

Hi Folks,

We have transactional replication setup to replicate data from production across to a reporting server.

We want to ARCHIVE production, but don't want the ARCHIVE duplicated on the reporting server.

Does anyone know of a way that the reporting server can be stopped from replicating these changes, and continue to hold the FULL history of the database?

Cheers,

David

View 2 Replies View Related

NOT Replicate Data Archive

Jun 5, 2002

Hi Folks,

We have transactional replication setup to replicate data from production across to a reporting server.

We want to ARCHIVE production, but don't want the ARCHIVE duplicated on the reporting server.

Does anyone know of a way that the reporting server can be stopped from replicating these changes, and continue to hold the FULL history of the database?

Cheers,

David

View 2 Replies View Related

Replicate A View With Data?

May 4, 2007

Hello,
I am trying to add a View to an existing publication and it the subscribers (all devices with SQL CE) don't get the View after replication. I have deleted and recreated the publication, and only the tables will appear on the device, not the view.

Also, I want the data from the view to be dynamic, filtered by using the Host_Name() function/value. Will this work for a View?

thanks
- will

View 3 Replies View Related

Replicate Table Additions And Modifications

Feb 23, 2007

I am new at replication and it has been going well, but have more of an information question that a problem. Basically I have transactional replication without updates. So i am pushing from the publisher to the subscriber only. I have added a table to the publisher side, and it is not replicating to the subscriber. Data pushes fine. I have read about reinitializing, adding article, etc. I do not know which is the way to go, I need it to happen automatically.

Which way and how? Any help is appreciated greatly.

Thanks

View 1 Replies View Related

Replicate Data From DB2 To SQL Server 2000

Feb 5, 2004

We have a distributed Database in DB2 and SQL Server 2000.
As the user updates/Inserts data to DB2 Database , the data need to be dynamically replicated to SQL Server.
Please Let me know the best possible method of doing it.
Thanks,
Ravi.

View 2 Replies View Related

How Do I Replicate Data From MySQL Into SQL-Server

Jul 23, 2005

Hello group,i am relatively new to SQL-Server database, but i have lots ofexperience with DB2 and Oracle Database. One of my tasks is setting upa replication between a Mysql-Database running on Linux and one of ourSQL-Servers.How do i achieve this ?If i understand the documentation correctly you have to program thereplication mechanism for yourself or you have to use some third partytool.Could anyone please outline, how to set up the replication mechanism(pointing me to some web-site should be enough) and also tell me ifthere is any third party tool.Thanks in advance and greetings from ViennaUli

View 1 Replies View Related

How Long It Take To Finish Replicate Data

Nov 1, 2006

I have a database A include five tables, and have more than 1,500,000 rows. There is a replica database of A. First of all, there is no data in the two dbs. When I finish inserting data into A, the replica db seems still work, the log file size still changes. How can I know the replication finished or not? How long it will take to finish replicate 1,500,000 rows of data?

View 1 Replies View Related

Replicate Data Only From SQL Express To SQLserver2005

Apr 20, 2006

We have merge replication, Publisher work on SQLserver2005
standard edition,


Subscriber work on
SQL Express. My problem is following.


Considering that the Subscriber is on SQL Express we can use
only Merge replication.


Is it possible to develop merge replication to replicate
data only from Subscriber to Publisher.

View 1 Replies View Related

Create An Indexed View And Replicate To Table

Mar 20, 2008

All,

I have a huge problem to solve.

1) Need to create an Indexed View that joins multiple tables.I know how to create a regular View, but How do I create an Indexed View ?

2)Need be able to replicate the Indexed View [above] across to another server B into a table.

I have to get this done and seriously don't know where to start.

Do HELP me out .Thank You.

View 2 Replies View Related

New Table Added To P-t-p Transactional Publication Does Not Replicate - Why?

Feb 15, 2007

Hello,

We are new to replication and are testing it in our development environment. We have a peer-to-peer transactional publication on our three servers. The single table in the original publication replicated fine to the two subscribing servers. We next added a new table (article) to the publication. Adding it to the original publication worked fine but the table did not replicate to the other servers. (We previously had changed the schema of the original table and the schema changes replicated properly.) We attempted to recreate the snapsnot using the "View Snapshot Agent Status" option. Clicking the Start button resulted in the display of this message: "[0%] A snapshot was not generated because no subscriptions needed initialization."

This seems odd because a new table was added to the publication and Microsoft help states that the snapshot must be rebuilt. I have read other topics that refer to a @immediate_sync property that must be set to zero. I'm not sure if this is our problem or even how to set this value. Meanwhile, the other servers, as viewed through the Replication Monitor, are complaining that their snapshots do not match the publication snapshot.

Can someone point me in the right direction?

Thanks,

BCB

View 1 Replies View Related

Emulator Error To Replicate Data On SQL Server

Aug 18, 2005

Hi Guys,

View 7 Replies View Related

Data Added Before Publication Created Does Not Replicate - Why?

Feb 15, 2007

Hello,

I have a small three server development environment where I am getting my feet wet with replication. I have set up peer-to-peer transactional replication and it works fine for data added to the publication's table after the publication was created. However, rows in the table that existed prior to the publication's creation have never replicated. If any of the "old" rows are edited they cause an error on the subscribing servers when the replicator attempts to apply updates to rows that do not exist.

How can I get the old rows that predate the publication to replicate?

Thanks,

BCB

View 1 Replies View Related

Replicate Data From DB2/AS400 To SQL Server 2005

Sep 11, 2007

Hi Guys

I am trying to replicate data from DB2/AS400 to SQL Server2005 (ENT edition) currently we use 3rd party tool to replicate data from DB2 to SQL Server2000 (ENT edition) and like to get rid of this 3rd party tool. I am searching for the last 3 weeks but didn€™t get a good starting point. I have linked DB2 to SQL Server2005 and can run queries against DB2/AS400 box. Now I want to set up transactional replication from DB2 to SQL Server 2005. I have read about peer to peer topologies but I don€™t know if that€™s the route I have to take?



So can someone please help me? I really appreciate your help.



Thanks

Tariq

View 1 Replies View Related

Replicate Data Driven Query Task(DTS) In SSIS

Sep 6, 2007

I am migrating DTS packages to SSIS (recreating all the logic).
I have a Data Driven Query task in DTS with

Source query - select x,y from table1 (from database db1)
Binding - table2 which contains columns which match table1 x,y (fron database db2)
Transformation - maping from source table1 x,y to Binding table2 x,y
Queries - type update update table2 set x=? where y=?

I know that there is no similar task in SSIS,can someone tell me how to replicate this in SSIS

Thanks in Adv

View 5 Replies View Related

Replication :: Replicate All Data From Remote Locations To Central Location

Aug 29, 2015

there are several remote locations where sql is running, my company has asked me to find a way to collect all the data from the remote locations to a central location automatically,for example day to day data should be synced at night time from 2am to 7 am and it should be compressed automatically before data transfers to the central location. NOTE there is no domain only standalone workstations

View 3 Replies View Related

Replication :: Replicate Data From 3 Publishers To A Single / Central Subscriber Transactionally?

Oct 15, 2015

Is it possible to replicate data from 3 publishers to a single/central subscriber transactionally? In other words I have Server A, Server B, Server C with databases A,B,C respectively. I need to replicate 2 articles from A,2 from B and 2 from C to a central Server D that hosts database D. D will have only 6 articles. The replication is Transactional Replication.

If it is possible what will be the drawbacks of such implementation? (if one server goes down will the whole replication break?) If not possible then what is the best way of implementing this?

View 3 Replies View Related

Delete Rows With Duplicate Column Data But Unique Row Data

May 25, 2000

Hello,

This probably has been addressed before but I was unable to get the search to work properly on this site.
I am needing a script/way of deleting all rows from a DB with the exception of one record left for each row that has duplicate column data. Example :
Row 1
Field1 = 12345 Field2 =xxxxx Field 3=yyyyy Field4=zzzzz etc.
Row 2
Field1 = 12345 Field2 =zzzzzz Field 3=xxxxxx Field4=yyyyyy etc.
Row3
Field1 = 12345 Field2 =20202 Field 3=11111 Field4=zzzzz etc.
Row 4
Field1 = 54321 Field2 =xxxxx Field 3=yyyyy Field4=zzzzz etc.
Etc. Etc.

I want to be able to find the duplicates for Field1 and then delete all but 1 of those rows.( I don't care which one I keep just so only one is left.) The data in the other fields may or may not be unique.

I know how to find the duplicates it's just the deleting part I am having problems with. Any help would be much appreciated. Thanks,

Kerry

View 3 Replies View Related







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