SELECT col1,col2,col3, case col4 when 0 then 'Approve' else 'Un-Approve' end as Approved as 'Colum4', col5 FROM tblTest
Tuesday, October 12, 2010
case statement in sql query.
Labels:
SQL
Tuesday, September 7, 2010
How to Set Dynamically order by Clause in sql Query ?
DECLARE @iSort int SET @iSort = 3 SELECT * FROM tableName order by case when @iSort = 1 then Column1 end asc, case when @iSort = 2 then Column2 end desc, case when @iSort = 3 then Column3 end asc, case when @iSort = 4 then Column4 end desc
Saturday, August 28, 2010
How to Show and Hide Div Using JavaScript?
Labels:
Java Script
How to Convert Number in Indian Currency format(like lakh and crore format)?
A method to convert any number in indian curreny format in words.
public string NumberToText(int number) { if (number == 0) return "Zero"; if (number == -2147483648) return "Minus Two Hundred and Fourteen Crore Seventy Four Lakh Eighty Three Thousand Six Hundred and Forty Eight"; int[] num = new int[4]; int first = 0; int u, h, t; System.Text.StringBuilder sb = new System.Text.StringBuilder(); if (number < 0) { sb.Append("Minus "); number = -number; } string[] words0 = {"" ,"One ", "Two ", "Three ", "Four ", "Five " ,"Six ", "Seven ", "Eight ", "Nine "}; string[] words1 = {"Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ","Sixteen ","Seventeen ","Eighteen ", "Nineteen "}; string[] words2 = {"Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ","Eighty ", "Ninety "}; string[] words3 = { "Thousand ", "Lakh ", "Crore " }; num[0] = number % 1000; // units num[1] = number / 1000; num[2] = number / 100000; num[1] = num[1] - 100 * num[2]; // thousands num[3] = number / 10000000; // crores num[2] = num[2] - 100 * num[3]; // lakhs for (int i = 3; i > 0; i--) { if (num[i] != 0) { first = i; break; } } for (int i = first; i >= 0; i--) { if (num[i] == 0) continue; u = num[i] % 10; // ones t = num[i] / 10; h = num[i] / 100; // hundreds t = t - 10 * h; // tens if (h > 0) sb.Append(words0[h] + "Hundred "); if (u > 0 || t > 0) { if (h > 0 || i == 0) sb.Append("and "); if (t == 0) sb.Append(words0[u]); else if (t == 1) sb.Append(words1[u]); else sb.Append(words2[t - 2] + words0[u]); } if (i != 0) sb.Append(words3[i - 1]); } return sb.ToString().TrimEnd(); }
Labels:
C#
Monday, August 23, 2010
Auto Generated Serial Number in a SQL Query
select ROW_NUMBER() over (order by ID) as RowNumber from tableName
Labels:
SQL
How to Convert Date in dd-MM-yyyy format in Sql ?
select convert(varchar(50),getdate(),105)
Labels:
SQL
What is partial Class in ASP .NET C-Sharp ?
Instead of defining an entire class, you can split the definition into multiple classes by using the partial keyword. When the application is complied, the C# complier will group all the partial classes together and treat them as a single class. There are a couple of good reasons to use partial classes. Programmers can work on different parts of a class without needing to share the same physical file. Also you can separate your application business logic from the designer-generated code
Labels:
C#
Subscribe to:
Posts (Atom)