Brian's Blog

items I see across my tribes

SQL Server Cast

July 22
by briancarter 22. July 2010 07:09

The SQL Server cast function is the easiest data type conversion function to be used. It takes only one parameter followed by the AS clause to convert a specified value.

A quick example is the following:

SELECT
    UserID_String = CAST(UserID AS varchar(50))
FROM dbo.User

Categories: Development

Comments

7/28/2010 4:24:04 PM #

I prefer CAST cos its ANSI-Standard and can be used as is in other RDBMS systems such as MySql and Oracle.

Sai United States


 Questions or Feedback, my contact information is located on my About page.


The opinions, thoughts, and comments made in these blog posts are solely my own (unless otherwise stated). They do not reflect the opinions, thoughts or practices of my employer, my universities, my family, or anyone else. Also, I retain the right to change my mind about anything I publish here without having to go back and edit posts that occurred in the past. 

These are my opinions, or just as likely, someone else's opinions that I leveraged for my own.