how to match columns to data in sql

Posted by Jayakumars under ASP.NET AJAX on 10/16/2012 | Points: 10 | Views : 1014 | Status : [Member] [MVP] | Replies : 1
hi

here how to match TABle100Q Data match to Table100A Column

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Table100Q](
[ID] [int] IDENTITY(1,1) NOT NULL,
[QCode] [varchar](50) NULL,
CONSTRAINT [PK_Table100] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
SET IDENTITY_INSERT [dbo].[Table100Q] ON
INSERT [dbo].[Table100Q] ([ID], [QCode]) VALUES (1, N'Q1')
INSERT [dbo].[Table100Q] ([ID], [QCode]) VALUES (2, N'Q2')
INSERT [dbo].[Table100Q] ([ID], [QCode]) VALUES (3, N'Q3')
INSERT [dbo].[Table100Q] ([ID], [QCode]) VALUES (4, N'Q4')
INSERT [dbo].[Table100Q] ([ID], [QCode]) VALUES (5, N'Q5')
SET IDENTITY_INSERT [dbo].[Table100Q] OFF


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Table100A](
[Id] [int] NULL,
[Q1] [varchar](50) NULL,
[Q2] [varchar](50) NULL,
[Q3] [varchar](50) NULL,
[Q4] [varchar](50) NULL,
[Q5] [varchar](50) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
INSERT [dbo].[Table100A] ([Id], [Q1], [Q2], [Q3], [Q4], [Q5]) VALUES (1, N'1', N'2', N'3', N'1', N'2')
INSERT [dbo].[Table100A] ([Id], [Q1], [Q2], [Q3], [Q4], [Q5]) VALUES (2, N'2', N'1', N'1', N'2', N'1')
INSERT [dbo].[Table100A] ([Id], [Q1], [Q2], [Q3], [Q4], [Q5]) VALUES (3, N'3', N'2', N'1', N'2', N'1')
INSERT [dbo].[Table100A] ([Id], [Q1], [Q2], [Q3], [Q4], [Q5]) VALUES (4, N'1', N'3', N'2', N'2', N'1')

Mark as Answer if its helpful to you


Responses

Posted by: Krv on: 11/6/2012 [Member] Starter | Points: 25

Up
0
Down
select a.*.b.* from Table100Q a join Table100A on a.id=b.id


Thanks,
R.Vasanth
MCTS(SQL Server & BI)
http://bigdatatech.blogspot.com

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response