Search This Blog

Thursday, December 30, 2010

Select a random records SQL SERVER, Oracle, MySql

Database > Random Records

--Select random rows with Microsoft SQL Server
--NEWID Creates a unique value of type uniqueidentifier.

SELECT * FROM table ORDER BY NEWID()

--Select random rows with MySQL
SELECT * FROM table ORDER BY RAND()

--Select random records with Oracle:
SELECT * FROM table ORDER BY dbms_random.value









How to extract words out from a string c#

C# > String > Spilt
 
Split returns a string array that contains the substrings in this instance that are delimited by elements of a specified Unicode character array. 


Example
 
string _strInput = "aaa bbb ccc ddd";
string[] words = _strInput.Split ( new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries );
foreach(string s in words)
{
  // value of s: aaa, bbb, ccc, ddd
}