Step 1 - You have to first create Temporary table.
NAME NVARCHAR(100),
USER_NAME NVARCHAR(200),
EMAIL NVARCHAR(200),
MOBILE_NUMBER NVARCHAR(50),
ADDRESS NVARCHAR(200)
)
Step 2 - Insert records into the temporary table.
INSERT INTO @USERTEMPTABLE(NAME,USER_NAME,EMAIL,MOBILE_NUMBER,ADDRESS)
VALUES
('RAMAN SACHDEVA','RMN_001','***@gmail.com','98780*****','CHANDIGARH'),
('ANAND SACHDEVA','ANAD_051','***@gmail.com','99520*****','CHANDIGARH'),
('ROHIT SACHDEVA','RHT_250','***@gmail.com','87520*****','CHANDIGARH'),
('ARUN SHARMA','ARN_002','***@gmail.com','95140*****','MOHALI'),
('SURINDER SINGH','SRN_300','***@gmail.com','98520*****','JALANDHAR'),
('KULWINDER SINGH','KLN_1000','***@gmail.com','87550*****','AMRITSAR'),
('PALKA SACHDEVA','PLK_550','***@gmail.com','98560*****','CHANDIGARH'),
('AKASHDEEP SINGH','AKSH_121','***@gmail.com','79851*****','DELHI'),
('HARISH KUMAR','HRSH_050','***@gmail.com','79862*****','MUMBAI'),
('FATEH SINGH','FTH_660','***@gmail.com','96468*****','PUNE')
After inserting the records, you can fetch all the records from temporary table with the below query.
SELECT * FROM @USERTEMPTABLE
Here is an example of inserting a records into the temorary table. Please see the screenshot for further clarification.
DECLARE @USERTEMPTABLE TABLE
(
ID INT PRIMARY KEY IDENTITY(1,1),
(
ID INT PRIMARY KEY IDENTITY(1,1),
NAME NVARCHAR(100),
USER_NAME NVARCHAR(200),
EMAIL NVARCHAR(200),
MOBILE_NUMBER NVARCHAR(50),
ADDRESS NVARCHAR(200)
)
Step 2 - Insert records into the temporary table.
INSERT INTO @USERTEMPTABLE(NAME,USER_NAME,EMAIL,MOBILE_NUMBER,ADDRESS)
VALUES
('RAMAN SACHDEVA','RMN_001','***@gmail.com','98780*****','CHANDIGARH'),
('ANAND SACHDEVA','ANAD_051','***@gmail.com','99520*****','CHANDIGARH'),
('ROHIT SACHDEVA','RHT_250','***@gmail.com','87520*****','CHANDIGARH'),
('ARUN SHARMA','ARN_002','***@gmail.com','95140*****','MOHALI'),
('SURINDER SINGH','SRN_300','***@gmail.com','98520*****','JALANDHAR'),
('KULWINDER SINGH','KLN_1000','***@gmail.com','87550*****','AMRITSAR'),
('PALKA SACHDEVA','PLK_550','***@gmail.com','98560*****','CHANDIGARH'),
('AKASHDEEP SINGH','AKSH_121','***@gmail.com','79851*****','DELHI'),
('HARISH KUMAR','HRSH_050','***@gmail.com','79862*****','MUMBAI'),
('FATEH SINGH','FTH_660','***@gmail.com','96468*****','PUNE')
After inserting the records, you can fetch all the records from temporary table with the below query.
SELECT * FROM @USERTEMPTABLE
Here is an example of inserting a records into the temorary table. Please see the screenshot for further clarification.
- - - - - - - - - - - - - - - - - - - - - - - - Cheers, Happy to Help! - - - - - - - - - - - - - - - - - - - - - - - - - - -
What is the use of temp table?
ReplyDeleteTemporary table are used to store and process the immediate results. It is very useful when we need to store temporary data.
DeleteThen what is the difference between normal table & temp table ?
DeleteTemp table acts like a physical table and its created or stored in tempdb database.You can do any operation in temp table as you do with the normal table. Normal table are the permanent table which store the information permanently. Temp table works like as a session to store data in temp table.
Delete