collie
Constraint Violating Yak Guru
400 Posts |
Posted - 2013-11-20 : 11:10:49
|
[code]Hi,I have to compare data from 2 tables on 2 different servers with different formats.USE [TestDB]GO/****** Object: Table [dbo].[Table_4] Script Date: 11/20/2013 18:03:47 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE TABLE [dbo].[Table_4]( [idno] [int] NULL, [columns] [int] NULL, [percentage] [int] NULL) ON [PRIMARY]GOINSERT [dbo].[Table_4] ([idno], [columns], [percentage]) VALUES (1, 1, 34)INSERT [dbo].[Table_4] ([idno], [columns], [percentage]) VALUES (1, 2, 89)INSERT [dbo].[Table_4] ([idno], [columns], [percentage]) VALUES (2, 1, 45)INSERT [dbo].[Table_4] ([idno], [columns], [percentage]) VALUES (2, 2, 7)INSERT [dbo].[Table_4] ([idno], [columns], [percentage]) VALUES (2, 3, 12)INSERT [dbo].[Table_4] ([idno], [columns], [percentage]) VALUES (3, 2, 5)INSERT [dbo].[Table_4] ([idno], [columns], [percentage]) VALUES (3, 3, 18)/****** Object: Table [dbo].[Table_3] Script Date: 11/20/2013 18:03:47 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE TABLE [dbo].[Table_3]( [idno] [int] NULL, [column1] [int] NULL, [column2] [int] NULL, [column3] [int] NULL) ON [PRIMARY]GOINSERT [dbo].[Table_3] ([idno], [column1], [column2], [column3]) VALUES (1, 23, 45, 0)INSERT [dbo].[Table_3] ([idno], [column1], [column2], [column3]) VALUES (2, 28, 67, 5)INSERT [dbo].[Table_3] ([idno], [column1], [column2], [column3]) VALUES (3, 12, 7, 67)idno column1 column2 column31 23 45 02 28 67 53 12 7 67 The other table Table_4 looks like thisidno columns percentage1 1 341 2 892 1 452 2 72 3 123 2 53 3 18[/code]I need to get table_3 in the same format as Table_4 so that I can compare the data from the 2 tables.I need to get idno and check if the value for column1 in table_3 is the same as percentage in table_4 for same idno where column=1. It will be easier to get the tables in the same format. I prefer getting table_3 in the same format as table_4.How can i get the same format? I need to use a temp table.Thanks |
|