SQL Tech Insider-3---Variable declaration method similar to Temporal table usage

Source: Internet
Author: User

-----directly on the code

--Declares a variable of type table declare @table table (name varchar, name2 varchar (500))--Raw data SELECT * FROM dbo. Customers-Inserts the data into the temporary variable insert into @table SELECT * from  dbo. Customers--The data in the variable select * from @table

-Results---

--Raw data

CustomerID City
Fissa Madrid
Frndo Madrid
Krlos Madrid
Mrphs Zion

---data in a variable

Name Name2
Fissamadrid
Frndomadrid
Krlosmadrid
Mrphszion

---The following method of using temporary tables, the result is the same

CREATE  TABLE #temp (name varchar, name2 varchar)  SELECT * FROM dbo. Customers INSERT into #temp SELECT * from  dbo. Customers SELECT * from #tempDROP TABLE #temp

  

SQL Tech Insider-3---Variable declaration method similar to Temporal table usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.