Wednesday, March 28, 2012

Inverse -- Reverse

Hi,
I am not able to slove my problem so guys i need ur help.
i had (thousands) of records in my database in this manner.
Name Id
DFDDABBF-7079-4135-AAD8-1BDA58DB0CEB
Now i need the Nameid like below
BFABDDDF-7970-3541-AAD8-1BDA58DB0CEB
I need changes till 18 character started from left handside.
Thanx for ur help.
from
Dollerdoller
It is completely . Do you need to change/reverse only the left
side of the data?
It is not exactly what you wanted but if you explain what are you trying
to achive so we may suggets better solution
Anyway , I tried to give an idea.
CREATE TABLE #Test (col VARCHAR(50) NOT NULL)
INSERT INTO #Test VALUES ('DFDDABBF-7079-4135-AAD8-1BDA58DB0CEB')
SELECT REVERSE(col) FROM #Test
SELECT STUFF(col, 1, CHARINDEX('-',col), 'BFABDDDF-')
FROM #Test
"doller" <sufianarif@.gmail.com> wrote in message
news:1142831035.525419.135860@.t31g2000cwb.googlegroups.com...
> Hi,
> I am not able to slove my problem so guys i need ur help.
> i had (thousands) of records in my database in this manner.
> Name Id
> DFDDABBF-7079-4135-AAD8-1BDA58DB0CEB
>
> Now i need the Nameid like below
> BFABDDDF-7970-3541-AAD8-1BDA58DB0CEB
> I need changes till 18 character started from left handside.
> Thanx for ur help.
> from
> Doller
>|||SOrry if u got confuse
Given Data
DFDDABBF-7079-4135-AAD8-1BDA58DB0CEB (given Data)
Needs like below
BFABDDDF-7970-3541-AAD8-1BDA58DB0CEB
I dont know how to do this (not sure use reverse or inverse).
from
Doller|||Well, you will be better of doing such things on the client side
"doller" <sufianarif@.gmail.com> wrote in message
news:1142833372.212324.309310@.i39g2000cwa.googlegroups.com...
> SOrry if u got confuse
> Given Data
> DFDDABBF-7079-4135-AAD8-1BDA58DB0CEB (given Data)
> Needs like below
> BFABDDDF-7970-3541-AAD8-1BDA58DB0CEB
> I dont know how to do this (not sure use reverse or inverse).
> from
> Doller
>|||Hi Umi,'
Thanx for ur help . !ha|||Was it sarcasm?
"doller" <sufianarif@.gmail.com> wrote in message
news:1142833924.710613.158210@.v46g2000cwv.googlegroups.com...
> Hi Umi,'
> Thanx for ur help . !ha
>|||"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:e3kfDH%23SGHA.5172@.TK2MSFTNGP12.phx.gbl...
> Well, you will be better of doing such things on the client side
I don't see why it can't be done on the server. It looks like a maintenance
job to fix a bug in the app. A simple update statement could fix it pretty
quick.

>
> "doller" <sufianarif@.gmail.com> wrote in message
> news:1142833372.212324.309310@.i39g2000cwa.googlegroups.com...
>|||Hi umi,
Why u think like this man .Ha actually mean yes.
If u think i do then i am sorry.
from
Doller|||doller wrote on 19 Mar 2006 21:03:55 -0800:

> Hi,
> I am not able to slove my problem so guys i need ur help.
> i had (thousands) of records in my database in this manner.
> Name Id
> DFDDABBF-7079-4135-AAD8-1BDA58DB0CEB
> Now i need the Nameid like below
> BFABDDDF-7970-3541-AAD8-1BDA58DB0CEB
> I need changes till 18 character started from left handside.
> Thanx for ur help.
Assuming the strings are in Col1 of your table Table1
SELECT REVERSE(LEFT(Col1,8)) + '-' + REVERSE(SUBSTRING(Col1,10,4) + '-' +
REVERSE(SUBSTRING(Col2,16,4) + SUBSTRING(Col1,20,17)
FROM Table1
Dan|||I think you want something like this:
DROP TABLE #tmp
CREATE TABLE #tmp ( nameid VARCHAR(50) PRIMARY KEY )
INSERT INTO #tmp VALUES( 'DFDDABBF-7079-4135-AAD8-1BDA58DB0CEB' )
-- INSERT INTO #tmp VALUES( 'BFABDDDF-7970-3541-AAD8-1BDA58DB0CEB' )
SELECT nameid,
SUBSTRING( nameid, 7, 2 ) +
SUBSTRING( nameid, 5, 2 ) +
SUBSTRING( nameid, 3, 2 ) +
SUBSTRING( nameid, 1, 2 ) +
SUBSTRING( nameid, 9, 1 ) +
SUBSTRING( nameid, 12, 2 ) +
SUBSTRING( nameid, 10, 2 ) +
SUBSTRING( nameid, 14, 1 ) +
SUBSTRING( nameid, 17, 2 ) +
SUBSTRING( nameid, 15, 2 ) +
SUBSTRING( nameid, 19, 18 )
FROM #tmp
Lookup using SUBSTRING, LEFT, RIGHT, REPLACE and STUFF in the SQL Help.
Let me know how you get on.
Damien
"doller" wrote:

> Hi,
> I am not able to slove my problem so guys i need ur help.
> i had (thousands) of records in my database in this manner.
> Name Id
> DFDDABBF-7079-4135-AAD8-1BDA58DB0CEB
>
> Now i need the Nameid like below
> BFABDDDF-7970-3541-AAD8-1BDA58DB0CEB
> I need changes till 18 character started from left handside.
> Thanx for ur help.
> from
> Doller
>

No comments:

Post a Comment