March 19, 2006 at 9:56 pm
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
Killer
March 19, 2006 at 10:15 pm
Is it uniqueidentifier?
_____________
Code for TallyGenerator
March 20, 2006 at 1:12 am
Yes it is.
from
Killer
March 20, 2006 at 3:10 am
Is there a reason why you can't just use substring? Like this...
--This SQL script is safe to run
DECLARE @t TABLE (Id INT IDENTITY, Name_Id UNIQUEIDENTIFIER)
INSERT @t
SELECT 'DFDDABBF-7079-4135-AAD8-1BDA58DB0CEB'
UNION SELECT NEWID()
UNION SELECT NEWID()
SELECT * FROM @t
SELECT
Id,
SUBSTRING(CAST(Name_Id AS VARCHAR(40)), 7, 2) +
SUBSTRING(CAST(Name_Id AS VARCHAR(40)), 5, 2) +
SUBSTRING(CAST(Name_Id AS VARCHAR(40)), 3, 2) +
SUBSTRING(CAST(Name_Id AS VARCHAR(40)), 1, 2) +
'-' +
SUBSTRING(CAST(Name_Id AS VARCHAR(40)), 12, 2) +
SUBSTRING(CAST(Name_Id AS VARCHAR(40)), 10, 2) +
'-' +
SUBSTRING(CAST(Name_Id AS VARCHAR(40)), 17, 2) +
SUBSTRING(CAST(Name_Id AS VARCHAR(40)), 15, 2) +
SUBSTRING(CAST(Name_Id AS VARCHAR(40)), 19, 20)
FROM
@t
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
March 20, 2006 at 6:51 am
If it's uniqueidentifier then it's not varchar, it's binary(16).
Treat it as it is, not as it seems to you.
P.S. Substring works for binary strings as well.
_____________
Code for TallyGenerator
March 21, 2006 at 1:51 am
Hi Sergily,
It is in binary ex:0x...... but i removed 0x from the bignning of the records, i transfered the record in a varchar field as written above.
I am not good at programming i need the data like this
Q: ABVFHG-1234-4563-ASDEFF-2345-5673
Ans : HGVFAB-3412-6345-ASDEFF -2345-5673
from
Killer
March 21, 2006 at 2:14 am
Hi,
Thanx a lot , it run so well.
from
Killer
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply