Drop Table
Support Forum for database administrators and web based access to important newsgroups related to databasesHi 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.
Post Follow-up to this messageSo 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.
Post Follow-up to this messageIf 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. >
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread