Updating data

This is a discussion on Updating data within the sqlserver-tools forums in Microsoft SQL Server category; Hello again, ive got a table with a column that normally contains a number, for example, 4057. But there are some that finishes with an a, for example, 4057a. I want to quit the a and place a 1 instead, so in the last example, the 4057a will be a 40571. The column name is called ID and the table name is called dbo.runners Many thanks....

Go Back   Database Forum > Microsoft SQL Server > sqlserver-tools

Database Forums

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-22-2008, 05:30 PM
Default Updating data

Hello again, ive got a table with a column that normally contains a number,
for example, 4057. But there are some that finishes with an a, for example,
4057a. I want to quit the "a" and place a "1" instead, so in the last
example, the 4057a will be a 40571.

The column name is called ID and the table name is called dbo.runners

Many thanks.
Reply With Quote
  #2  
Old 08-27-2008, 11:35 AM
Default RE: Updating data


Try it,

you can use restrict update clause by putting more conditions in where clause.

update dbo.runners set id=replace(id,'a','1') where charindex('a',id)>0
Reply With Quote
Reply


Thread Tools
Display Modes



All times are GMT -4. The time now is 08:38 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Integrated by bbpixel2008 :: jvbPlugin R1013.368.1

Search Engine Friendly URLs by vBSEO 3.1.0
vB Ad Management by =RedTyger=
In an effort to better serve ads to our visitors, cookies are used on Mydatabasesupport.com. For more information, check out our Privacy Policy.