473,394 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Update using Substring

I have a SQL Table I am trying to update...I would like to add '-000' to the end of every value in a column, GLSegment.

I can do this for one row using this statement...

UPDATE CmpnyGLSegments
SET GLSegment = (SELECT SUBSTRING (GLSegment, 1, 3) FROM CmpnyGLSegments WHERE RowID = 2)+'-000'
WHERE RowID = 2

but do not know how to do this for every row at once. I would like to take each existing GLSegment value for each row, and add '-000'.

Thanks for any help you can provide.
Sep 18 '06 #1
4 18594
I have a SQL Table I am trying to update...I would like to add '-000' to the end of every value in a column, GLSegment.

I can do this for one row using this statement...

UPDATE CmpnyGLSegments
SET GLSegment = (SELECT SUBSTRING (GLSegment, 1, 3) FROM CmpnyGLSegments WHERE RowID = 2)+'-000'
WHERE RowID = 2

but do not know how to do this for every row at once. I would like to take each existing GLSegment value for each row, and add '-000'.

Thanks for any help you can provide.
UPDATE CmpnyGLSegments
SET GLSegment = GLSegment + '-000'
Sep 19 '06 #2
Thanks for the help!
Sep 19 '06 #3
Kgirl
2
Hi!! Can I delete '-000' instead of adding ?????????
I would like to delete '-000' at the begining of every value in a column, how can I do that???
Jan 26 '07 #4
iburyak
1,017 Expert 512MB
[PHP]UPDATE CmpnyGLSegments
SET GLSegment = Replace(GLSegment, '-000','')[/PHP]
Jan 26 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: J.P | last post by:
Hi! Anyone knows if it's possible to do an update if, and only if my condition is TRUE. Example: In MYTABLE I have three columns, like this: ID(INT), PUBLISH(ENUM(Y,N)),...
10
by: sqlgoogle | last post by:
Hi I'm trying to update a db based on the select statement which has ORDER BY in it. And due to that I'm getting error which states that Server: Msg 1033, Level 15, State 1, Line 13 The ORDER...
3
by: Dave [Hawk-Systems] | last post by:
Have a table with fnumber and number, both text fnumber is a phone number, format "8005551212" number needs to be the same number but in the format "(800) 555-1212" we currently run the...
3
by: Munno | last post by:
Hi All, I am not so proficient in SQL and seek your help. I have a column by the name of Mask in a table, which has text eg. (YYYYYYYNNNNYYYYYYYYYNNYYYY). I wanted to update one particular...
2
by: Al Willis | last post by:
Hello, I've written an insert trigger to fill in data on 5 columns based on the key field column after a record is added to a table. The trigger works fine. But what I also want to do is to...
1
by: Brad Isaacs | last post by:
Using ASP.NET 2.0 with SQL Server 2000 Inside my dropdown list box I am using an SQL DataSource to select the following data SELECT RTRIM(c.Name_First) + ' ' + RTRIM(c.Name_Last) AS Contact,...
1
by: Dmitri | last post by:
Hi! I have a stored procedure that takes 22 minutes to run in one environment, that only takes 1 sec or so to run in another environment. Here is the exact situation: Database 1 on Server 1...
1
by: braintrust | last post by:
Can I use SQL (in an AS400 environment) to update a substring of a field? In this example, the update to the substring is conditional. Follows is the SQL syntax I used and the error message I...
0
by: mwenz | last post by:
I am trying to update an Access table using OLEDB in VB.Net 2005. I can add rows but I cannot update them. Code to instantiate the Access database and table... Dim conn As New...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.