May 23, 2008 at 6:13 am
I'm in situation I need to mask data for testing purpose and table do not have primary key to cursor for mask it . For example student table below I need to mask. I'm looking for logic to mask as below
OPEN c_table
FETCH NEXT FROM c_table INTO @table_counter
WHILE @@fetch_status = 0
BEGIN
UPDATE student
set class_id =
studnet_id =
ssn =
May 23, 2008 at 7:45 am
It looks to me like you can use a straight-up UPDATE statement without bothering with the cursor -- what is preventing this?
May 23, 2008 at 7:55 am
I'd have to agree with Kent, partly because you are only giving us a portion of what you are trying to do. It would help to see all of your code, not just a snippet.
May 23, 2008 at 8:38 am
I want to use cursor to do this way
OPEN c_table
FETCH NEXT FROM c_table INTO @table_counter
WHILE @@fetch_status = 0
BEGIN
UPDATE student
set class_id = "1234" so next row will be 1235 ....
studnet_id =
ssn =
May 23, 2008 at 8:42 am
Use a tally table for that. It's a lot more efficient:
http://www.sqlservercentral.com/articles/TSQL/62867/[/url]
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
May 23, 2008 at 9:04 am
Could also be a running total solution. Not having enough information it is hard to say. How about the DDL for the tables, sample data, and expected results. All of this will give you better results from your request for help.
Read this article, it will help you when asking for help: http://www.sqlservercentral.com/articles/Best+Practices/61537/
😎
May 23, 2008 at 1:47 pm
Why not just add IDENTITY column?
_____________
Code for TallyGenerator
May 23, 2008 at 3:29 pm
Why not, indeed... that would be the way to go...
--Jeff Moden
Change is inevitable... Change for the better is not.
May 23, 2008 at 3:33 pm
Could be, but it is hard to say when you don't have enough information to give a proper answer.
😎
May 23, 2008 at 5:34 pm
True enough...
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply