Showing posts with label reversing. Show all posts
Showing posts with label reversing. Show all posts

Tuesday, March 20, 2012

Reversing string concatenation

Hi,

How can I remove a part of string from complete string in SQL?

this is something i want to do:

update ace
set PICTURE = PICTURE - '\\SHWETABH\Shwetabh\I\'

But here ' - ' is not allowed.

How can I remove the string \\SHWETABH\Shwetabh\I\ from the column
PICTURE?

Regards,
ShwetabhTry this
UPDATE ace
SET picture = Replace(Picture,'\\SHWETABH\Shwetabh\I\' , '')

Markus|||Also try

UPDATE ace
SET picture = Substring(Picture,1,charindex('-',Picture,1)-1)

Madhivanan|||Or if you know that the first part of the string is always going to be
'PICTURE' then simply use this:

update ace
set PICTURE = left(PICTURE, 7)|||Thanks Marcus,
That did the trick.

Now there is one more problem.
I know to add the string, the query is

UPDATE ace
SET PICTURE = '\\SHWETABH\Shwetabh\I\' + PICTURE

Now this query appends the string before PICTURE column contents.
Now is there a way that the contents having the string
'\\SHWETABH\Shwetabh\I\'
do not get updated with this string and only cells which do not have
the string get updated?

Shwetabh|||On 6 Apr 2006 02:32:02 -0700, Shwetabh wrote:

>Thanks Marcus,
>That did the trick.
>Now there is one more problem.
>I know to add the string, the query is
>UPDATE ace
>SET PICTURE = '\\SHWETABH\Shwetabh\I\' + PICTURE
>Now this query appends the string before PICTURE column contents.
>Now is there a way that the contents having the string
>'\\SHWETABH\Shwetabh\I\'
>do not get updated with this string and only cells which do not have
>the string get updated?

Hi Shwetabh,

UPDATE ace
SET PICTURE = '\\SHWETABH\Shwetabh\I\' + PICTURE
WHERE PICTURE NOT LIKE '\\SHWETABH\Shwetabh\I\%'

--
Hugo Kornelis, SQL Server MVP

Reversing Scale of Numeric Data

Hello:
To simplify my question, suppose I have one table with one field named
Score. Scores can be 1, 2, 3, 4, or 5. Here's how the table appears
originally:
Score
1
2
3
4
5
4
3
2
1
Suppose I wanted these values to be reversed, meaning I want all 1s to
be 5s, 2s to be 4s, 4s to be 2s, and 5s to be 1s. I'm looking for a
creative way of doing this using a stored procedure. I want make sure
that this procedure doesn't go through the entire table changing 1s to
5s first, then goes through the entire table again changing 2s to 4s,
followed by 4s to 2s, and finally 5s to 1s, as it would result in the
following:
Score
1
2
3
2
1
2
3
2
1
The desired result would be:
Score
5
4
3
2
1
2
3
4
5
Thanks,
DaveTry:
Update Table
set value = 6 - value

Reversing a soundex result

Hi everyone,
Hope you can help me with this one. Given a soundex value like:
"M500" how can you tell what the original value was as a charcter
string? In other words, how can you go back? (inside query analyzer?)
SELECT soundex('help') = H410
but if I was given H410 - how do I determine the string?
Comments/suggestions/code samples much appreciated...
Al
almurph@.altavista.com wrote:
> Hi everyone,
> Hope you can help me with this one. Given a soundex value like:
> "M500" how can you tell what the original value was as a charcter
> string? In other words, how can you go back? (inside query analyzer?)
> SELECT soundex('help') = H410
> but if I was given H410 - how do I determine the string?
>
> Comments/suggestions/code samples much appreciated...
> Al
You can't. It's a one-way algorithm since different character strings
can be represented by the same SOUNDEX value.
What is the problem you are trying to solve?
David Gugick - SQL Server MVP
Quest Software

Reversing a soundex result

Hi everyone,
Hope you can help me with this one. Given a soundex value like:
"M500" how can you tell what the original value was as a charcter
string? In other words, how can you go back? (inside query analyzer')
SELECT soundex('help') = H410
but if I was given H410 - how do I determine the string'
Comments/suggestions/code samples much appreciated...
Alalmurph@.altavista.com wrote:
> Hi everyone,
> Hope you can help me with this one. Given a soundex value like:
> "M500" how can you tell what the original value was as a charcter
> string? In other words, how can you go back? (inside query analyzer')
> SELECT soundex('help') = H410
> but if I was given H410 - how do I determine the string'
>
> Comments/suggestions/code samples much appreciated...
> Al
You can't. It's a one-way algorithm since different character strings
can be represented by the same SOUNDEX value.
What is the problem you are trying to solve?
David Gugick - SQL Server MVP
Quest Software

Reversing a soundex result

Hi everyone,
Hope you can help me with this one. Given a soundex value like:
"M500" how can you tell what the original value was as a charcter
string? In other words, how can you go back? (inside query analyzer')
SELECT soundex('help') = H410
but if I was given H410 - how do I determine the string'
Comments/suggestions/code samples much appreciated...
Alalmurph@.altavista.com wrote:
> Hi everyone,
> Hope you can help me with this one. Given a soundex value like:
> "M500" how can you tell what the original value was as a charcter
> string? In other words, how can you go back? (inside query analyzer')
> SELECT soundex('help') = H410
> but if I was given H410 - how do I determine the string'
>
> Comments/suggestions/code samples much appreciated...
> Al
You can't. It's a one-way algorithm since different character strings
can be represented by the same SOUNDEX value.
What is the problem you are trying to solve?
David Gugick - SQL Server MVP
Quest Software

Reversing a box checked in a moment of foolishness

Any idea how I can *blush* get my database server registration wizard back after checking the box next to the prompt "From now on I want to perform this task without using a wizard"?
I KNOW it said "from now on", but I didn't think it MEANT it ;)Originally posted by TallCowboy0614
Any idea how I can *blush* get my database server registration wizard back after checking the box next to the prompt "From now on I want to perform this task without using a wizard"?

I KNOW it said "from now on", but I didn't think it MEANT it ;)

Click Tools|Wizard... and you should be okay|||Tried that, but can't see anything that looks like it on any of the sub-lists for the wizards displayed.

Any idea what it's called? I looked for something like "server registration wizard" but can't find that or anything that looks like it.

(all this for trying to remove/reregister a server to get my SET QUOTED_IDENTIFIER ON
SET ANSI_NULLS ON

options to work when I create a new SP and/or FN - but I'll do a thread search and then come back on that one if I need to...)

Thanks,
Paul|||Why do you want it?

I couldn't turn it off fast enough...|||I'm not sure I DO want it...*LOL* Just new to the toolset, and didn't want to prematurely jettison a possible future option ;)|||Nah, don't worry, you don't need it...

There are potentially much more hazardous thing to really screw up...

Hav a nice day

:)|||T'Q then...and on to more hazardous stuff :D