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