onmyway365 .

onmyway365 .

  • NA
  • 39
  • 4.9k

SQL Query to update random records with data

Jan 19 2016 1:38 AM
Hi all,
 
I hope you can help me.
 
I am busy testing a C# app, and would like to update 200 database records with data for testing. I would like to update random 10% of certain fields with data. 
 
This is the table structure: 
 
SELECT [RowID]
,[Finance_Project_Number]
,[Finance_Project_Type]
,[Finance_Project_Description]
,[Finance_Project_Region]
,[Customer_Number]
,[Processing_Signal]
,[Processing_Result]
,[Processing_Result_Text]
,[Infor_Customer_Code]
,[Infor_Project_Number]
,[Insert_Datetime]
,[Processed_Datetime]
,[Infor_Row_ID]
,[Infor_Status]
,[Resolution_Message]
,[Resolution_Date]
FROM [InterfaceInfor].[dbo].[ProjectMaster]
 
I would like something like this (some pseudo code):
 
UPDATE TOP (200) * FROM [InterfaceInfor].[dbo].[ProjectMaster]
SET  ([Finance_Project_Number] = '' (random 10%),
         [Finance_Project_Type] = '' (random 10%), )
         [Finance_Project_Region]= 'GAUTENG' (random 10%), )
         [Processing_Result]= '0' (random 10%), ) 
         [Finance_Project_Type] = '' (random 10%) ) 
 
Thank you in advance!  
 
 
 

Answers (3)