开发者

Convert keyword in SQL Server 2005

开发者 https://www.devze.com 2022-12-16 13:19 出处:网络
I want to conver开发者_Python百科t a DATETIME field (DateOfBirth)... When I execute the following query it says invalid syntax near convert

I want to conver开发者_Python百科t a DATETIME field (DateOfBirth)... When I execute the following query it says invalid syntax near convert

SELECT e.Emp_Id,e.Emp_Name,e.Address,e.Department,
(convert(varchar, e.Date_Of_Birth, 103) as Date_Of_Birth) from Employee as e 

But when I execute the below query it gives result but my dateofbirth column name is (No Column Name)

SELECT e.Emp_Id,e.Emp_Name,e.Address,e.Department,
(convert(varchar, e.Date_Of_Birth, 103)) from Employee as e 

Why cant I give an alias name as column name to a convert function?


Drop the extra comma:

SELECT e.Emp_Id,e.Emp_Name,e.Address,e.Department, 
convert(varchar, e.Date_Of_Birth, 103) as Date_Of_Birth
FROM Employee as e  
0

精彩评论

暂无评论...
验证码 换一张
取 消