Idea about query in comparing

Hello all
Anyone have me a suggestion about case:

  • I have column Id,Name,Age in Excel File
  • I have large table with greater 500K rows in tableA (Id,Name,Age)
    My task:
    I have to get all rows in tableA with sameId in excel file and if Age >50 , i will add status column in output.
    How can i solve this problem ?
    Thank you so much !

Welcome,

Maybe something like this

create table #willslap(Id int, Name varchar(150), age int)

BULK INSERT #willslap FROM 'C:\tmp\data.csv'
   WITH (
      FIELDTERMINATOR = ',',
      ROWTERMINATOR = '\n'
);
GO



select case 
         when k.Age > 50 then 'Oldie But Goodie' 
		 else 'Young Buck' 
		 end Status, * 
  From 500k k
  join #willslap ws on k.id = ws.id

drop table #willslap