Simple operation of table data for SQL Server

Source: Internet
Author: User

--Table data manipulation--
-- Add Table Data --
-- adding data to an existing table --
[Use the database name to manipulate the data table
Go
Insert [into] datasheet [(Field name 1, field name 2, field name 3, ...)] VALUES (value 1, value 2, value 3, ...)

Cases:
Use Commodity Management database
Go
Insert Customer Information Form (customer name, customer number, contact phone) values (' Contacts ', ' 021 ', ' 13927112594 ')

-- generate (add to) a new data table from the table data being queried--
[Use the database name to manipulate the data table
Go
Select field List into new data table name from source data table name [WHERE condition expression]

Cases:
Use Commodity Management database
Go
SELECT * into stock information table from arrival information table where quantity <100

-- Add the queried table data to an existing data table (number of fields, order, and data type to be compatible)--
[Use the database name to manipulate the data table
Go
Insert into is added data already exists data table Select field list from source data table [where condition expression]

Cases:
Use Commodity Management database
Go
Insert into incoming information table, select product number, purchase price, quantity of goods, purchase amount, arrival date from arrival information table where incoming quantity >300


-- modifying table data --
Update the data table name to be modified set field name = new Value [, ...] [From data table list] [Where Condition expression]

Cases:
Use Commodity Management database
Go
Update customer Information table Set mailbox = ' [email protected] ' where customer number = ' 001 '

-- Delete table data --
Delete data table name [from data table list] [where conditional expression] --delete table data only does not delete data table

Cases:
Use Commodity Management database
Delete Customer Information table where customer number = "001"


-- table data query --

SELECT * | field name [, field Name 2, ...] from data table name [WHERE condition expression]

Cases:
Use Commodity Management database
Go
SELECT * From commodity information table
Select product number, product name, origin from product information Form
SELELCT * FROM product information sheet where origin = ' Shenyang, Liaoning '

Note: "--" for the comment text

Simple operation of table data for SQL Server

Related Article

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.