CONVERT(varchar(12), OrderDate, 111) : VARCHAR « Data Types « SQL Server / T-SQL Tutorial






4>
5> CREATE TABLE Orders (
6>      OrderID int NOT NULL ,
7>      CustomerID nchar (5) NULL ,
8>      EmployeeID int NULL ,
9>      OrderDate datetime NULL ,
10>     RequiredDate datetime NULL ,
11>     ShippedDate datetime NULL ,
12>     ShipVia int NULL ,
13>     Freight money NULL DEFAULT (0),
14>     ShipName nvarchar (40) NULL ,
15>     ShipAddress nvarchar (60) NULL ,
16>     ShipCity nvarchar (15) NULL ,
17>     ShipRegion nvarchar (15) NULL ,
18>     ShipPostalCode nvarchar (10) NULL ,
19>     ShipCountry nvarchar (15) NULL
20> )
21> GO
1>
2>    SELECT OrderDate, CONVERT(varchar(12), OrderDate, 111) AS "Converted"
3>    FROM Orders
4>    WHERE OrderID = 11050
5> GO
OrderDate               Converted
----------------------- ------------

(0 rows affected)
1>
2> drop table orders;
3> GO








5.27.VARCHAR
5.27.1.To use a string literal or a date literal in a comparison, enclose it in quotes.
5.27.2.Varchar type value pattern matching
5.27.3.Selecting the length of a varchar column.
5.27.4.How to concatenate string data
5.27.5.How to format string data using literal values
5.27.6.How to include apostrophes in literal values
5.27.7.VARCHAR(MAX)
5.27.8.Replace the string '102' located at offset 9 (zero-based) with the string 'one hundred and two'
5.27.9.City name is Dallas
5.27.10.The IN() Function matches a field to any number of values in a list.
5.27.11.Use REPLICATE to fill a varchar type variable
5.27.12.CONVERT(varchar(12), OrderDate, 111)
5.27.13.Performing String Concatenation