When an insert statement is used, what data needs to be enclosed by quotation marks and what data does not need to be enclosed by quotation marks? Solution

Source: Internet
Author: User

When an insert statement is used, what data needs to be enclosed by quotation marks and what data does not need to be enclosed by quotation marks?
Create Database mydb

Use mydb
Create Table customer_data
(
Customer_id smallint,
First_name char (20 ),
Last_name char (20 ),
Phone char (10)
)
Go


Insert into customer_data
(Customer_id, first_name, last_name, phone)
Values (777, 'frankie', 'stein ', '123 ')
The preceding insert statement: I see that smallint fields do not need to be enclosed by quotation marks. Char fields are all enclosed by quotation marks. What other data types are enclosed by quotation marks and what is not included in quotation marks?

------ Solution --------------------------------------------------------
Quotation marks are required for char, nchar, varchar, nvarchar, text, and ntext of the string type.
The date type must also be enclosed by quotation marks,
Numeric type, logical type without quotation marks.
------ Solution --------------------------------------------------------
Single quotation marks are required for varchar, Char, nvarchar, nchar, text, ntext, and datetime.
Int, numeric, bit does not need to be added

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.