Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

conversion
Hi All,

I am pretty new to sql server. I have a column with data in the format
of #ddd,dddd
where d is a number between 0 and 9.
e.g. one entry of column #34,56

What is the easiest way to convert it to integer? #56,5-->565

Thanks a lot

Thanks.


Report this thread to moderator Post Follow-up to this message
Old Post
jack.smith.sam@gmail.com
10-31-06 05:15 AM


Re: conversion
So the comma is not significant?  If so, try:

select
cast (replace (replace (MyCol, '#', ''), ',', '') as int)

--
Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON   Canada

<jack.smith.sam@gmail.com> wrote in message
news:1162070389.388509.50190@m7g2000cwm.googlegroups.com...
Hi All,

I am pretty new to sql server. I have a column with data in the format
of #ddd,dddd
where d is a number between 0 and 9.
e.g. one entry of column #34,56

What is the easiest way to convert it to integer? #56,5-->565

Thanks a lot

Thanks.



Report this thread to moderator Post Follow-up to this message
Old Post
Tom Moreau
10-31-06 05:15 AM


Re: conversion
If you want to permanently convert  the column datatype to integer, use
Tom's suggestion to clear the non-numeric characters out of the current
column, and then use

ALTER TABLE MyTable
ALTER COLUMN Mycolumn int

--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous

You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf


<jack.smith.sam@gmail.com> wrote in message
news:1162070389.388509.50190@m7g2000cwm.googlegroups.com...
> Hi All,
>
> I am pretty new to sql server. I have a column with data in the format
> of #ddd,dddd
> where d is a number between 0 and 9.
> e.g. one entry of column #34,56
>
> What is the easiest way to convert it to integer? #56,5-->565
>
> Thanks a lot
>
> Thanks.
>



Report this thread to moderator Post Follow-up to this message
Old Post
Arnie Rowland
10-31-06 05:15 AM


Sponsored Links





Last Thread Next Thread
Post New Thread

MS SQL Server archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 09:17 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006