Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 22nd, 2004, 01:39 PM
Authorized User
 
Join Date: Oct 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default Different between CAST and CONVERT functions

Hi all,

What are the differences between CAST and CONVERT functions in SQL statement specially for SQLSERVER ?

Thanks in advance

John

 
Old October 22nd, 2004, 10:18 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

CAST is based on the SQL-92 standard and is preferred over CONVERT

Jaime E. Maccou
Applications Analyst
 
Old October 24th, 2004, 12:00 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

SELECT CONVERT(char(8),GETDATE(),112)

In the above example CONVERT() offers superior functionality to CAST(),CONVERT ()supports a style parameter (the third argument above) that specifies the exact format to use when converting a datetime value to a character string.





Similar Threads
Thread Thread Starter Forum Replies Last Post
CAST or CONVERT in Access owain SQL Language 12 November 28th, 2013 05:56 AM
Specified cast is not valid. abstar BOOK: ASP.NET Website Programming Problem-Design-Solution 2 March 31st, 2005 03:00 PM
cast problem vickyj General .NET 6 September 8th, 2004 06:21 AM
Query String Cast or Convert function hoffmann Access 6 February 25th, 2004 01:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.