-
Dec 7th, 2008, 01:33 PM
#1
Thread Starter
Lively Member
-
Dec 7th, 2008, 01:51 PM
#2
Re: Sql Server Columns Update Issue!
You can do something as simple as this:
update food
set plant = 'GRANNY SMITH APPLE FRUIT'
where plant = 'APPLE FR'
or if you know exact id then this:
update food
set plant = 'GRANNY SMITH APPLE FRUIT'
where food_id = 1
-
Dec 7th, 2008, 02:01 PM
#3
Thread Starter
Lively Member
Re: Sql Server Columns Update Issue!
Originally Posted by RhinoBull
You can do something as simple as this:
update food
set plant = 'GRANNY SMITH APPLE FRUIT'
where plant = 'APPLE FR'
or if you know exact id then this:
update food
set plant = 'GRANNY SMITH APPLE FRUIT'
where food_id = 1
thanks RhinoBull for your help
But I'm looking to how add text to the values not replacing them
Any idea please...
-
Dec 7th, 2008, 02:35 PM
#4
Re: Sql Server Columns Update Issue!
update food
set plant = 'GRANNY SMITH ' + plant + 'UIT'
where food_id = 1
-
Dec 8th, 2008, 09:39 AM
#5
Thread Starter
Lively Member
Re: Sql Server Columns Update Issue!
-
Dec 8th, 2008, 09:57 AM
#6
Re: Sql Server Columns Update Issue!
Couldn't you lift the code from brucevde's sample and modify it to suit your need? Just replace the value in the WHERE criteria.
-
Dec 8th, 2008, 10:07 AM
#7
Thread Starter
Lively Member
Re: Sql Server Columns Update Issue!
Originally Posted by dee-u
Couldn't you lift the code from brucevde's sample and modify it to suit your need? Just replace the value in the WHERE criteria.
I’ve try it, but I couldn’t know how solve it
Because the adding in the middle of the values!! My level of programming in SQL is beginner
-
Dec 8th, 2008, 10:10 AM
#8
Re: Sql Server Columns Update Issue!
So show us what you tried and why it is wrong
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Dec 8th, 2008, 10:14 AM
#9
Thread Starter
Lively Member
Re: Sql Server Columns Update Issue!
Originally Posted by GaryMazzone
So show us what you tried and why it is wrong
update food
set plant = 'CHERRY TOMATO' + plant + 'UIT'/'ETABLE'
where food_id = 3
-
Dec 8th, 2008, 10:19 AM
#10
Re: Sql Server Columns Update Issue!
What is it you want to write here? You are trying to do a division on strings that is not possible!
maybe:
sql Code:
update food
set plant = 'CHERRY TOMATO' + plant + 'UIT / ETABLE'
where food_id = 3
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Dec 8th, 2008, 10:32 AM
#11
Thread Starter
Lively Member
Re: Sql Server Columns Update Issue!
Originally Posted by GaryMazzone
What is it you want to write here? You are trying to do a division on strings that is not possible!
maybe:
sql Code:
update food
set plant = 'CHERRY TOMATO' + plant + 'UIT / ETABLE'
where food_id = 3
I’m really confused, sorry but I didn’t understand what you mean…
As I have said I’m newbie in the SQL …
Anyway thanks for your support
-
Dec 8th, 2008, 10:44 AM
#12
Re: Sql Server Columns Update Issue!
What you wrote means
Set plant = 'CHERRY TOMATO' + plant + 'UIT'/'ETABLE'
That the string plant Add CHERRY TOMATO before the value in plant then add UIT after the value of plant.
Next in the statment is a division (/) then the string 'ETABLE' which mean that the value 'CHERRY TOMATO' + plant + 'UIT' (which is a string) and divide it by the value 'ETABLE' (which is also a string). That is not allowed.
I assume (and of course I can be wrong here) you want to and the string
'UIT / ETABLE' after the current value in the plant field.
Is that correct?
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Dec 8th, 2008, 10:46 AM
#13
Re: Sql Server Columns Update Issue!
You wrote -
'UIT' / 'ETABLE' in you code. The / character is the Division character for dividing numbers (4 / 2 = 2) so you would in effect be trying to divide words.
Try this instead -
UPDATE food
SET Plant = 'CHERRY ' + left(Plant,9) + 'UIT/' + right(Plant,3) + 'ETABLE'
WHERE food_id = 3
Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you
-
Dec 8th, 2008, 10:49 AM
#14
Re: Sql Server Columns Update Issue!
OK I just looked at you first post as to what you want that is more dificult
CHERRY TOMATO FRUIT/VEGETABLE is what you want and what you have is
TOMATO FR/VEG
What is the database you are using to store the data in it will make a difference in how you do this.
You will need to add CHERRY to the first part of the string then use a substring to add the UIT then andother substring to add the ETABLE to the ending
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Dec 8th, 2008, 11:25 AM
#15
Thread Starter
Lively Member
Re: Sql Server Columns Update Issue!
Originally Posted by NeedSomeAnswers
You wrote -
'UIT' / 'ETABLE' in you code. The / character is the Division character for dividing numbers (4 / 2 = 2) so you would in effect be trying to divide words.
Try this instead -
UPDATE food
SET Plant = 'CHERRY ' + left(Plant,9) + 'UIT/' + right(Plant,3) + 'ETABLE'
WHERE food_id = 3
That’s what I’m looking for
Many thanks NeedSomeAnswers
-
Dec 8th, 2008, 11:28 AM
#16
Thread Starter
Lively Member
Re: Sql Server Columns Update Issue!
Originally Posted by GaryMazzone
OK I just looked at you first post as to what you want that is more dificult
CHERRY TOMATO FRUIT/VEGETABLE is what you want and what you have is
TOMATO FR/VEG
What is the database you are using to store the data in it will make a difference in how you do this.
You will need to add CHERRY to the first part of the string then use a substring to add the UIT then andother substring to add the ETABLE to the ending
I appreciate your effort and time for helping…
Best regards
-
Dec 8th, 2008, 11:44 AM
#17
Re: [RESOLVED] Sql Server Columns Update Issue!
No Problem
Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|