November 15, 2010 at 10:14 am
What would be delete statement
for this
I want to delete KSCHLKO FROM 'KSHLKO100' WHICH IS LOCATED IN COLUMN
Thank you in advance
November 15, 2010 at 10:34 am
November 15, 2010 at 12:22 pm
DELETE ABCDEF FROM dbo.XYZ
WHERE Column = 'ABCDEF100'
November 15, 2010 at 12:25 pm
Thank you for your reply. Per your advice,
I created
DELETE ABCDEF FROM dbo.XYZ
WHERE Column = 'ABCDEF100'
want to delete ABCDEF AND LEAVE 100 IN THAT COLUMN
Plz help me create statement for this one
Any input is appreciated
November 15, 2010 at 12:25 pm
wannalearn (11/15/2010)
DELETE ABCDEF FROM dbo.XYZWHERE Column = 'ABCDEF100'
Where are you getting DELETE ABCDEF ? Look in BOL for the basic format of a DELETE statement. It should follow the format that I showed you above....
DELETE t
FROM dbo.XYZ t
WHERE Column = 'ABCDEF100'
November 15, 2010 at 12:27 pm
wannalearn (11/15/2010)
Thank you for your reply. Per your advice,I created
DELETE ABCDEF FROM dbo.XYZ
WHERE Column = 'ABCDEF100'
want to delete ABCDEF AND LEAVE 100 IN THAT COLUMN
Plz help me create statement for this one
Any input is appreciated
Then you want to do an UPDATE, not a DELETE.....DELETE will remove the row from the database.....UPDATE will change the value of a column.
UPDATE dbo.XYZ
SET Column = 'ABCDEF'
WHERE Column = 'ABCDEF100'
November 15, 2010 at 12:29 pm
wannalearn (11/15/2010)
Thank you for your reply. Per your advice,I created
DELETE ABCDEF FROM dbo.XYZ
WHERE Column = 'ABCDEF100'
want to delete ABCDEF AND LEAVE 100 IN THAT COLUMN
Plz help me create statement for this one
Any input is appreciated
What RDBMS did you originally learn to write SQL in (I mean that seriously, not snidely, very odd format)? That's a propietary method if it works at all.
You want UPDATE, not DELETE. UPDATE changes values in an existing row, DELETE removes the row entirely. So, You want something along the lines of:
UPDATE table
SET Column = '100'
WHERE Column = 'ABCDEF'
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
November 15, 2010 at 12:34 pm
Thank you for your input.
I want to update in SQL. Your advice worked but only one row is affected from it. If I want to update all records in that field. How do i do it?
November 15, 2010 at 12:36 pm
Are all the rows getting the same update? If so, modify the Where clause to include all the rows you want.
If not, what are some sample rows?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
November 15, 2010 at 12:46 pm
Yes, I just have to remove ABCDEF and leave integer in that column. all records have ABCDEF.... ( similar values) in that table.
UPDATE TABLE
SET COLUMN = '0...' (THIS AREA)
WHERE COLUMN = 'ABCDEF...'(THIS AREA)
What should I do in this area or value section to update all records in that column?
Thanks
November 15, 2010 at 12:57 pm
My previous example updated the wrong part of the column...thanks to Craig for doing it correctly.
DECLARE @Table TABLE (Val varchar(100))
INSERT INTO @Table
SELECT 'ABCDEF100' UNION ALL
SELECT 'ABCDEF200' UNION ALL
SELECT 'ABCDEF300'
SELECT * FROM@Table
UPDATE @Table
SET Val = SUBSTRING(Val, 7, LEN(Val))
WHERELEFT(Val,6) = 'ABCDEF'
SELECT * FROM@Table
November 15, 2010 at 1:06 pm
sample rows as you requested
XYZ
ABCDEF1010
ABCDEF1012
ABCDEF102
ABCDEF1026
ABCDEF1030
ABCDEF1032
ABCDEF1044
November 15, 2010 at 1:12 pm
Update dbo.MyTable
set Column = replace(Column, 'ABCDEF', '')
where Column like 'ABCDEF%';
Does that get what you need?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
November 15, 2010 at 1:33 pm
sample rows as you requested
XYZ
ABCDEF1010
ABCDEF1012
ABCDEF102
ABCDEF1026
ABCDEF1030
ABCDEF1032
ABCDEF1044
November 15, 2010 at 1:36 pm
Thank you so much..
It worked.
Viewing 15 posts - 1 through 15 (of 18 total)
You must be logged in to reply to this topic. Login to reply