Author |
Topic |
monty
Posting Yak Master
130 Posts |
Posted - 2006-10-31 : 20:52:35
|
Hi All,I need a script that will manipulate string values, like names for example, to change them to another value. I don't want a script that changes all values in a character column to the same value. What I'm looking for is a script that will change that column in each row to a different value. The purpose is to protect the identity of the original name in the row but to still maintain some uniqueness between rows.looking forward 4ur helpmontyits me monty |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-10-31 : 20:58:18
|
You have to provide more information for us to help you. Like table strucutre, sample data and the expected result KH |
 |
|
monty
Posting Yak Master
130 Posts |
Posted - 2006-10-31 : 21:28:24
|
khtan,only this basic idea is given to me even iam not aware of the structure due to some security reasons iam supposed to just give a rough idea or a procedure to move on frm this basic idea...plz help me outits me monty |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-10-31 : 21:43:12
|
"due to some security reasons"You don't have to post the actual table structure. Just a simple structure with data that can illustrate your requirement. KH |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-10-31 : 21:59:30
|
"I need a script that will manipulate string values, like names for example, to change them to another value. I don't want a script that changes all values in a character column to the same value. What I'm looking for is a script that will change that column in each row to a different value. The purpose is to protect the identity of the original name in the row but to still maintain some uniqueness between rows."Basically you can look up the string manipulation function on Books OnLine.Like replace(), left(), substring(), right() etc. Can't help you much without knowing specific requirement. KH |
 |
|
monty
Posting Yak Master
130 Posts |
Posted - 2006-11-02 : 21:06:44
|
Hi Khtan,suppose that coloumn has:1:cat2:bat3:matit should be changed to something like :1:cmaot(cats new value)2:bmaot(bats new value)its just an examplesome thing like encrption and we need to preserve the unquienesslooking 4all ur helpits me monty |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-11-02 : 21:22:13
|
if it is some sort of one to one replacement, you can use a mapping table to do it-- Your original tablecreate table #table1( col varchar(10))-- the mapping table that stores what change to whatcreate table #mapping( old varchar(10), new varchar(10))-- insert the sample data for testinginsert into #table1select 'cat' union allselect 'bat' union allselect 'mat'insert into #mappingselect 'cat', 'cmaot' union allselect 'bat', 'bmaot'-- before updateselect * from #table1-- update with mappingupdate tset col = m.newfrom #table1 t inner join #mapping m on t.col = m.old-- after updateselect * from #table1 KH |
 |
|
monty
Posting Yak Master
130 Posts |
Posted - 2006-11-02 : 21:52:04
|
Hi khtan,thanks alot for such a quick response... i did test the code it looks gud, but it cld be gr8 if u cld help me out with a code where:1)first it parses a coloumn(varchar) in each row 2)replaces that coloumn with a random value(character)3)retrives the modified coloumn of each rowbasically the idea here is to preserve the uniqueness of each coloumn..to be precise similar to encryption..iam xreamly sorry if i mislead u earliear..thanks in advanceits me monty |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-11-02 : 22:07:30
|
cld be iam xreamly gr8 if u cld xpln gud en inglis. thxCODO ERGO SUM |
 |
|
monty
Posting Yak Master
130 Posts |
Posted - 2006-11-02 : 22:15:10
|
what do u mean?infact i dont understand ur english..its me monty |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-11-02 : 22:29:15
|
quote: Originally posted by monty what do u mean?infact i dont understand ur english..its me monty
cld u xpln y? i wud b xreamly gr8fool.CODO ERGO SUM |
 |
|
Arnold Fribble
Yak-finder General
1961 Posts |
Posted - 2006-11-03 : 03:32:42
|
quote: Originally posted by montyinfact i dont understand ur english..
I don't think they spoke English in Ur; it's more probable that the early settlers spoke Sumerian. |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-03 : 03:40:13
|
Well, substitution is not encryption...Peter LarssonHelsingborg, Sweden |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-11-03 : 21:05:05
|
quote: Originally posted by Arnold Fribble
quote: Originally posted by montyinfact i dont understand ur english..
I don't think they spoke English in Ur; it's more probable that the early settlers spoke Sumerian.
Ur was inhabited in the Ubaid period around 5300 BCE, while it is only known that the Sumerian language was spoken by about 4000 BCE, so it's hard to be sure.CODO ERGO SUM |
 |
|
monty
Posting Yak Master
130 Posts |
Posted - 2006-11-04 : 08:07:09
|
Hi khtan,Thanks for ur help, i got the script for which i was looking please have a look at it :DECLARE @ROWID INT, @I INT, @UPDATED_VALUE VARCHAR(150), @NEW_VALUE INT, @CHECK INTSET @I = 1SET @CHECK = (SELECT COUNT(*) FROM TEST)SET @RowID = 1WHILE (@ROWID < @CHECK+1) BEGIN SET @UPDATED_VALUE = (SELECT STUFF(LNAME, 2, 4, RAND(@ROWID)) FROM TEST WHERE ID = @ROWID) UPDATE Test SET LNAME = @UPDATED_VALUE WHERE ID = @ROWID SET @ROWID = @ROWID + 1 END--select COUNT(*) from test_table--SELECT * FROM TESTits me monty |
 |
|
|