A small application of Insert -- copying data

Source: Internet
Author: User

The deeper the study, the more profound the knowledge.

The Insert method in SQL is insert into Table value (). When using the SQL Insert statement today.

Implement a function to copy a piece of data. The primary key is different and the data is the same.

Example:

1. Table Structure

The environment is SQL Server2008.

2. Code

(1) Replace the Value statement with the select statement,

(2) In the select statement, replace the primary key with the primary key of the insert statement.

Insert into Student (No, Name, Sex, Age)
Select 2, Name, Sex, Age
From Student
Where No = 1

3. Description

At first, you must have a data record and then copy it.

It is very easy to use and useful at critical moments.

I hope this small example will help you understand SQL.

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.