Re: how to scramble data in a table
From: Dan Guzman (danguzman_at_nospam-earthlink.net)
Date: 02/16/04
- Next message: E70925: "re: Avoid returning resultset from stored procedure"
- Previous message: lindawie: "Re: Avoiding Rowguid as PrimaryKey, is my idea workable???"
- In reply to: SND: "Re: how to scramble data in a table"
- Next in thread: Steve Kass: "Re: how to scramble data in a table"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 15 Feb 2004 23:43:04 -0600
Sorry, I misread your post. Hopefully, Steve's answer is more help.
-- Dan Guzman SQL Server MVP "SND" <sndip@cox.net> wrote in message news:G0YXb.1489$Mf.977@okepread04... > This won't work in my case since I have a million records and I would have > to build a very large dynamic Case statement. Sorry for making it confusing > with my sample data. > > "Dan Guzman" <danguzman@nospam-earthlink.net> wrote in message > news:Oi1hirD9DHA.2672@TK2MSFTNGP10.phx.gbl... > > If you don't mind using modulo on PersonID instead of RAND, you can > > accomplish this with set-based processing using CASE expressions. > > > > UPDATE Person > > SET > > LastName = CASE PersonID % 3 > > WHEN 0 THEN 'Smith' > > WHEN 1 THEN 'Adams' > > WHEN 2 THEN 'Doe' > > END, > > FirstName = CASE PersonID % 3 > > WHEN 0 THEN 'John' > > WHEN 1 THEN 'Greg' > > WHEN 2 THEN 'John' > > END, > > MiddleName = CASE PersonID % 3 > > WHEN 0 THEN 'D' > > WHEN 1 THEN 'B' > > WHEN 2 THEN 'C' > > END > > > > -- > > Hope this helps. > > > > Dan Guzman > > SQL Server MVP > > > > "SND" <sndip@cox.net> wrote in message > news:d4WXb.1477$Mf.1107@okepread04... > > > Does anyone have a neat way to scramble data in one table? > > > > > > I have a Person table with fields (PersonID, LastName, FirstName, > > > MiddleName). PersonID is a sequential number from 1 - 1,000,000 and > there > > > are NO gaps in the sequence. I need the last names to be scrambled with > > > last names and so forth. ie. Smith, John D. could become Adams, Greg > B. > > > > > > The only way I know how to accomplish this is by looping through each > > Person > > > record and then select 3 random PersonID using the RAND() function and > > then > > > update the current PersonID with the LastName, FirstName, and Middle > names > > > of the rand() persons. This process works but, since I have a million > > > records, it takes my server close to 30 minutes to process. > > > > > > Does anyone know of a faster process to accomplish this? > > > > > > > > > > > >
- Next message: E70925: "re: Avoid returning resultset from stored procedure"
- Previous message: lindawie: "Re: Avoiding Rowguid as PrimaryKey, is my idea workable???"
- In reply to: SND: "Re: how to scramble data in a table"
- Next in thread: Steve Kass: "Re: how to scramble data in a table"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|