Here’s a handy query for finding duplicates in a table using the GROUP BY and HAVING statement. Suppose you want to find all email addresses in a table that exist more than once: SELECT email, COUNT(email) AS NumOccurrences FROM users GROUP BY email HAVING ( COUNT(email) > 1 ) You could also use this technique […]
Month: July 2007
Inline IF’ Statement
C# string s; s = (true ? “True” : “False”); //s will be “True” VB.NET Dim s As String s = If(True, “True”, “False”) ‘s will be “True” ‘In the following you cannot rely on a particular function ‘not being called if the other argument is selected by Expression ‘(notice IIf vs. If) s = […]
DateTime Format String
DateTime now = new DateTime(2006, 9, 07, 15, 06, 01, 08, DateTimeKind.Local); now.ToString(); //”09/27/2006 15:06:01″ Year now.ToString(“%y”); //”6″ now.ToString(“yy”); //”06″ now.ToString(“yyy”); //”2006″ now.ToString(“yyyy”); //”2006″ Month now.ToString(“%M”); //”9″ now.ToString(“MM”); //”09″ now.ToString(“MMM”); //”Sep” now.ToString(“MMMM”); //”September” Day now.ToString(“%d”); //”7″ now.ToString(“dd”); //”07″ now.ToString(“ddd”); //”Thu” now.ToString(“dddd”); //”Thursday” Hour now.ToString(“%h”); //”3″ now.ToString(“hh”); //”03″ now.ToString(“hhh”); //”03″ now.ToString(“hhhh”); //”03″ now.ToString(“%H”); //”15″ now.ToString(“HH”); //”15″ […]