Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Duplicating ID

$
0
0

Hi ,

I have two tables .Test1 table goes well with inserting data into table  .

But I want to  Test2   Test_ID should references to Test1(ID).Can anyone please  help .How to join this query.

CREATE TABLE [dbo].[Test1](
	[id] [int] IDENTITY(1,1) NOT NULL,
          [bble] [nvarchar](max) NULL,
	[phone] [nvarchar](max) NULL,

Output of Test1 table

id bble name 1 1008110021 Diane Fields 2 1008110031 Diane Fields 3 1008120022 Diane Fields 4 1008140019 Daniela Zustovich 5 1008350041 John Mannella 6 1010280056 John Natale 7 1012760042 Kyle Nevergold 8 1008110021 Diane Fields 9 1008110031 Diane Fields 10 1008120022 Diane Fields 11 1008140019 Daniela Zustovich 12 1008350041 John Mannella 13 1010280056 John Natale 14 1012760042 Kyle Nevergold


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]


CREATE TABLE [dbo].[Test2](
	[s_Id] [int] IDENTITY(1,1) NOT NULL,
	[Test_Id] [int] NULL,references  Test1(id)
	,
	[ques_1] [varchar](max) NULL,
	[ques_2a] [varchar](max) NULL,
	[ques_2b] [varchar](max) NULL,
	[ques_2c] [varchar](max) NULL,
	[ques_3] [varchar](max) NULL)

output of Test2 table Test_ID after 7 it shows again 1 to 7 but i want 8 to 14

s_Id Test_ID ques_1 1 1 88 2 2 73 3 3 88 4 4 87 5 5 87 6 6 77 7 7 65 8 1 88 9 2 73 10 3 88 11 4 87 12 5 87 13 6 77 14 7 65 22 1 88 23 2 73 24 3 88




Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>