Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
ERROR
CREATE TABLE [dbo].[Table1]( [id] uniqueidentifier NOT NULL , [id2] uniqueidentifier NOT NULL, [name] nvarchar(max) NOT NULL CONSTRAINT [PK_Table1] PRIMARY KEY CLUSTERED ( [id] ASC )) GO CREATE NONCLUSTERED INDEX [IX_Table2_ID2] ON [dbo].[Table1] ( [id2] ASC ) ALTER TABLE [dbo].[Table1] ADD CONSTRAINT [DF_Id] DEFAULT (newsequentialid()) FOR [id] GO CREATE TABLE [dbo].[Table2]( [id] uniqueidentifier NOT NULL, [name] varchar(10) CONSTRAINT [PK_Table2] PRIMARY KEY CLUSTERED ( [id] ASC )) GO ALTER TABLE [dbo].[Table2] ADD CONSTRAINT [DF_Id2] DEFAULT (newsequentialid()) FOR [id] Declare @loop int = 1 while @loop<=10 begin insert into Table2 ([name]) Values(char((rand()*25 + 65))+char((rand()*25 + 65))+char((rand()*25 + 65))+char((rand()*25 + 65))) set @loop = @loop+1 end set @loop = 1 while @loop<2000 begin insert into Table1 (ID2, [name]) select ID,char((rand()*25 + 65))+char((rand()*25 + 65))+char((rand()*25 + 65))+char((rand()*25 + 65)) from Table2 set @loop = @loop+1 end select top 100 table1.Name,table2.Name from table1 WITH (NOLOCK) left join table2 on table1.ID2= table2.ID order by table2.ID desc,table1.ID desc
run
|
edit
|
history
|
help
0
exp7
Except Insert missing
Teset
20181cse0012dbmsca2
count events by 2 shift cycles using derived table
#Temp table Collation fixed
practice sql_12AUG_Upddated
test1
Left join producing wrong result
Week 6 Data Base IET