Sunday, December 4, 2011
Thursday, December 1, 2011
Can you crack It !!!
EB 04 AF C2 BF A3 81 EC 00 01 00 00 31 C9 88 0C
0C FE C1 75 F9 31 C0 BA EF BE AD DE 02 04 0C 00
D0 C1 CA 08 8A 1C 0C 8A 3C 04 88 1C 04 88 3C 0C
FE C1 75 E8 E9 5C 00 00 00 89 E3 81 C3 04 00 00
00 5C 58 3D 41 41 41 41 75 43 58 3D 42 42 42 42
75 3B 5A 89 D1 89 E6 89 DF 29 CF F3 A4 89 DE 89
D1 89 DF 29 CF 31 C0 31 DB 31 D2 FE C0 02 1C 06
8A 14 06 8A 34 1E 88 34 06 88 14 1E 00 F2 30 F6
8A 1C 16 8A 17 30 DA 88 17 47 49 75 DE 31 DB 89
D8 FE C0 CD 80 90 90 E8 9D FF FF FF 41 41 41 41
Can you crack it ???
Friday, July 8, 2011
Difference between Row Number, Rank and Dense Rank
What is the Difference between ROW_NUMBER, RANK and DENSE_RANK? Which one to use?
This is very common question in the minds of SQL newbie's. -- create table
Lets take 1 simple example to understand the difference between 3.
First lets create some sample data :
CREATE TABLE Salaries
(
Names VARCHAR(1),
SalarY INT
)
GO
-- insert data
INSERT INTO Salaries SELECT
'A',5000 UNION ALL SELECT
'B',5000 UNION ALL SELECT
'C',3000 UNION ALL SELECT
'D',4000 UNION ALL SELECT
'E',6000 UNION ALL SELECT
'F',10000
GO
-- Test the data
SELECT Names, Salary
FROM Salaries
Now lets query the table to get the salaries of all employees with their salary in descending order.
For that I'll write a query like this :
SELECT names |
NAMES | SALARY | ROW_NUMBER | RANK | DENSE_RANK |
F | 10000 | 1 | 1 | 1 |
E | 6000 | 2 | 2 | 2 |
A | 5000 | 3 | 3 | 3 |
B | 5000 | 4 | 3 | 3 |
D | 4000 | 5 | 5 | 4 |
C | 3000 | 6 | 6 | 5 |
Interesting Names in the result are employee A, B and D.
Row_number assign different number to them.
Rank and Dense_rank both assign same rank to A and B.
But interesting thing is what RANK and DENSE_RANK assign to next row?
Rank assign 5 to the next row, while dense_rank assign 4.
The numbers returned by the DENSE_RANK function do not have gaps and always have consecutive ranks. The RANK function does not always return consecutive integers. The ORDER BY clause determines the sequence in which the rows are assigned their unique ROW_NUMBER within a specified partition.
So question is which one to use?
Its all depends on your requirement and business rule you are following.
1. Row_number to be used only when you just want to have serial number on result set. It is not as intelligent as RANK and DENSE_RANK.
2. Choice between RANK and DENSE_RANK depends on business rule you are following. Rank leaves the gaps between number when it sees common values in 2 or more rows. DENSE_RANK don't leave any gaps between ranks.
So while assigning the next rank to the row RANK will consider the total count of rows before that row and DESNE_RANK will just give next rank according to the value.
So If you are selecting employee’s rank according to their salaries you should be using DENSE_RANK and if you are ranking students according to there marks you should be using RANK(Though it is not mandatory, depends on your requirement.)
Tuesday, June 7, 2011
Rajesh Hamal Jokes
- Rajesh Hamal inserts his Visiting Card in Any ATM & Collects Cash.
- Ghosts sit around the campfire and tell RAJESH HAMAL stories.
- Shahrukh khan was born in Nepal. He wanted to be a SuperStar. Knowing it would be impossible to top Rajesh dai in Kollywood, Sharukh went to Bollywood.
- Once Rajesh Hamal was having his dinner, right then he became angry with his mom and threw his dinner plate on the air… Now people refer it as FLYING SAUCER or UFO!!
- Last monday Rajesh Dai updated status in his wall. “Osama bin laden dead )” After few minutes, A notification came on his profile. “Osama Bin Laden likes your status” :O
- God walks on the water… but RAJESH HAMAL swims across the dry land !!!
- One day Rajnikanth, Spiderman , Superman, Batman,Bruce lee and Chuck Norris visited Rajesh dai’s house … it was an auspicious day of GURU PURNIMA !!!
- Rajesh Hamal can race with a bullet and win.
- Rajesh Hamal can divide by zero.
- Guns don’t kill people. Rajesh Hamal kills people.
- There is no such thing as global warming. Rajesh Hamal was cold, so he turned the sun up.
- Rajesh Hamal has counted to infinity. Twice !!!
- When Rajesh Hamal falls in water, Rajesh Hamal doesn’t get wet. Water gets Rajesh Hamal.
- When you say “No one’s Perfect”, Rajesh Hamal takes this as a personal insult.
- Rajesh Hamal doesn’t actually write books, the words assemble themselves out of fear. (Wish I could do that for my blog posts.)
- The pen is mightier than the sword, but only if the pen is held by Rajesh Hamal.
- Rajesh Hamal can retrieve items deleted from Recycle bin after shredding.
- Rajesh Hamal can delete the Recycle Bin.
- Rajesh Hamal doesn’t wear a watch. He decides what time it is.
- Rajesh Hamal once killed the sea & that sea is now called Dead Sea.
- Rajesh Hamal can slam a revolving door and he can make it reverse.
- Rajesh Hamal can make onions cry.
- Rajesh Hamal doesn’t breathe. Air hides in his lungs for protection.
- There are no weapons of mass destruction in Iraq because Rajesh Hamal lives in Katmandu.
- Rajesh Hamal killed Harry Potter so No Harry Potter’s Eighth book.
- Rajesh Hamal has already been to Mars, that’s why there are no signs of life there.
- Rajesh Hamal doesn’t move at the speed of light. Light moves at the speed of Rajesh Hamal.
- Rajesh Hamal kills two stones with one bird.
- Rajesh Hamal can easily handle the truth.
- Chuck Norris once met Rajesh Hamal. The result – He was reduced to a joke on the Internet.
- Rajesh Hamal’s calendar goes straight from March 31st to April 2nd, no one fools Rajesh Hamal.
- Words like awesomeness, brilliance, legendary etc. were added to the dictionary in the year 1964. That was the year Rajesh Hamal was born.
- Time and tide waits for no one but Rajesh Hamal.
- Rajesh Hamal can answer a missed call.
- Once a cobra bit Rajesh Hamal’ leg. After five days of excruciating pain, the cobra died.
- Ghosts are actually caused by Rajesh Hamal, its because of killing people faster than death can process them.
- When Rajesh Hamal looks in a mirror it shatters, because the mirror is not stupid enough to get in between the two Rajesh Hamals.
- Rajesh Hamal got his drivers license at the age of 16 Seconds.
- When studying, Rajesh Hamal used to practise the english spelling in his copies and collection of those are known as Oxford Dictionary nowadays.
- Rajesh Hamal does not use spell check. If he happens to misspell a word, Oxford will simply change the actual spelling of it.
- The Bermuda Triangle used to be the Bermuda Square, until Rajesh Hamal kicked one of the corners off.
- It takes Rajesh Hamal only 10 mins to watch 60 minutes.
- If you google search “Rajesh Hamal getting kicked” your search will generate 0 results. It just doesn’t happen.
- Rajesh Hamal’s house has no doors, only walls that he walks through.
- Rajesh Hamal grinds his coffee with his teeth and boils the water with his own rage.
- Rajesh Hamal once age an entire bottle of sleeping pills. They made him blink.
- The only thing that runs faster and longer than Rajesh Hamal are his films.
- Rajesh Hamal’s every step creates a mini whirlwind. Hurricane Katrina was the result of a morning jog.
- Where there is a will, there is a way. Where there is Rajesh Hamal there is no other way.
- Rajesh Hamal can build a snowman out of rain.
- Neil Armstrong was the first man to walk on the moon. Rajesh Hamal was the first man to walk on the sun.
Thursday, May 19, 2011
List of keyboard shortcuts in Mozilla Firefox
Navigation
Command________________ | Shortcut____________ |
Back | Altcommand+Left Arrow |
Forward | Altcommand+Right Arrow |
Home | AltOpt+Home |
Open File | Ctrlcommand+O |
Reload | F5 |
Reload (override cache) | Ctrl+F5 |
Stop | command+. |
Current Page
Command________________ | Shortcut____________ |
Go to Bottom of Page | End |
Go to Top of Page | Home |
Move to Next Frame | F6 |
Move to Previous Frame | Shift+F6 |
| Ctrlcommand+ I |
Page Source | Ctrlcommand+U |
| Ctrlcommand+P |
Save Page As | Ctrlcommand+S |
Ctrlcommand++ | |
Ctrlcommand+- | |
Ctrlcommand+0 |
Editing
Command________________ | Shortcut____________ |
Copy | Ctrlcommand+C |
Cut | Ctrlcommand+X |
Delete | Delete |
Paste | Ctrlcommand+V |
Redo | Ctrlcommand+YShift+Z |
Select All | Ctrlcommand+A |
Undo | Ctrlcommand+Z |
Search
Command________________ | Shortcut____________ |
Find | Ctrlcommand+F |
Find Again | F3 |
Find Previous | Shift+F3 |
Find As You Type Link | ' |
Find As You Type Text | / |
Ctrlcommand+K |
Windows & Tabs
See also Tabbed browsing
Command________________ | Shortcut____________ | |
Close Tab | Ctrlcommand+W | |
Close Window | Ctrlcommand+Shift+W | |
Move Tab in focus Left | Ctrlcommand+Left Arrow | |
Move Tab in focus Right | Ctrlcommand+Right Arrow | |
Move Tab in focus to start | Ctrlcommand+Home | |
Move Tab in focus to end | Ctrlcommand+End | |
New Tab | Ctrlcommand+T | |
New Window | Ctrlcommand+N | |
Next Tab | Ctrl+Tab | |
Open Address in New Tab | AltOpt+EnterReturn | - from Location Bar or Search Bar |
Previous Tab | CtrlCtrl+Shift+Tab |
|
Undo Close Tab | Ctrlcommand+Shift+T |
|
Undo Close Window | Ctrlcommand+Shift+N |
|
Select Tab (1 to 8) | CtrlAltcommand+(1 to 8) |
|
Select Last Tab | CtrlAltcommand+9 |
|
Tab Groups View | Ctrlcommand+ Shift+E |
|
History
Command________________ | Shortcut____________ |
History sidebar | Ctrlcommand+shift+H |
Library window (History) | Ctrl + Shift + H |
Bookmarks
Command________________ | Shortcut____________ |
Bookmark All Tabs | Ctrlcommand+ Shift+D |
Bookmark This Page | Ctrlcommand+D |
Bookmarks sidebar | Ctrlcommand+B |
Library window (Bookmarks) | Ctrlcommand+Shift+BO |
Tools
Command________________ | Shortcut____________ |
Ctrl + JCtrl + Shift + Ycommand + J | |
Add-ons | Ctrl + Shift + Acommand + Shift + A |
Error Console | Ctrl + Shift + Jcommand + Shift + J |
Web Console | Ctrl + Shift + Kcommand + Shift + K |
Toggle Private Browsing | Ctrl + Shift + Pcommand + Shift + P |
Ctrl + Shift + Del command + Shift + delete |
Miscellaneous
Command________________ | Shortcut____________ | |
Complete .com Address | Ctrlcommand+EnterReturn | |
Complete .net Address | Shift+EnterReturn | |
Complete .org Address | Ctrlcommand+Shift+EnterReturn | |
Delete Selected Autocomplete Entry | Shift+ Del | |
Toggle Full Screen | command+Shift+FF11 | |
HelpHelp | F1command+? | |
Toggle Menu Bar (when hidden) | Alt | |
Show/Hide Add-on Bar | Ctrl + /command + / | |
F7 | ||
Select Location Bar | Alt+D Ctrlcommand+L | |
Select or Manage Search Engines | AltOpt+Up Arrow | - when Search Bar is focused |
Media shortcuts (Ogg and WebM Videos Only)
Command________________ | Shortcut____________ |
Toggle Play / Pause | Space |
Decrease volume | Arrow down |
Increase volume | Arrow up |
Mute audio | Ctrl+Down Arrowcommand+Down Arrow |
Unmute audio | Ctrl+Arrow upcommand+Up Arrow |
Seek back 15 seconds | Left Arrow |
Seek back 10 % | Ctrl+Left Arrowcommand+Left Arrow |
Seek forward 15 seconds | Right Arrow |
Seek forward 10 % | Ctrl+Right Arrowcommand+Right Arrow |
Seek to the beginning | Home |
Seek to the end | End |
Monday, May 9, 2011
Function Split
CREATE FUNCTION [dbo].[ufn_Split](@String nvarchar(4000), @Delimiter char(1))
RETURNS @Results TABLE (value nvarchar(4000))
AS
--this function takes two parameters; the first is the delimited string, the second is the delimiter
-- Example how to use it >> IN (select value from dbo.ufn_Split(ltrim(rtrim(@CaseNumber)),','));
BEGIN
DECLARE @INDEX INT
DECLARE @SLICE nvarchar(4000)
-- HAVE TO SET TO 1 SO IT DOESNT EQUAL Z
-- ERO FIRST TIME IN LOOP
SELECT @INDEX = 1
IF @String IS NULL RETURN
WHILE @INDEX !=0
BEGIN
-- GET THE INDEX OF THE FIRST OCCURENCE OF THE SPLIT CHARACTER
SELECT @INDEX = CHARINDEX(@Delimiter,@STRING)
-- NOW PUSH EVERYTHING TO THE LEFT OF IT INTO THE SLICE VARIABLE
IF @INDEX !=0
SELECT @SLICE = LEFT(@STRING,@INDEX - 1)
ELSE
SELECT @SLICE = @STRING
-- PUT THE ITEM INTO THE RESULTS SET
INSERT INTO @Results(value) VALUES(@SLICE)
-- CHOP THE ITEM REMOVED OFF THE MAIN STRING
SELECT @STRING = RIGHT(@STRING,LEN(@STRING) - @INDEX)
-- BREAK OUT IF WE ARE DONE
IF LEN(@STRING) = 0 BREAK
END
RETURN
END
Thursday, April 21, 2011
Proxy Servers
Here is a free proxy list and proxy checker providing you with the best free proxies for over 8 years. Our sophisticated checking system measures many parameters of free proxy servers and combine them to compute our unique proxy rating. One index to rule them all :-) that includes dozens of various characteristics and how do they change in time. Only the best proxies receive the maximum rating 100. View our Proxy List Sorted By Rating!
15 Random With Highest Rating
trycatchme.com - United States
autoinsure.info - United States
freeurip.com - United States
sacredtunnel.info - United States
quickprox.info - Great Britain (UK)
go-fish.info - Singapore
freesafesurf.info - United States
connectionproxy.com - United States
stupidteacher.info - United States
runningnet.info - United States
blasttunnel.info - United States
tunnelworst.info - United States
wholebypass.info - United States
netwideopen.com - United States
tunnelaccess.info - United States
15 Newly Added Proxy Servers
bryanbrosfoundation.org - United States
allocationloansurf.info - United States
amortizedloansurf.info - United States
hide25.com - United States
proxyformyspace.info - United States
tunnelworst.info - United States
wholetunnel.info - United States
runningnet.info - United States
advertisementanonymous.info - United States
calculateforexsurf.info - United States
theanonymoussurf.info - United States
balancedfundloansurf.info - United States
approveforexsurf.info - United States
freedombyproxy.com - United States
tunnelaccess.info - United States
15 Proxies With Best Access Time
trycatchme.com - United States
autoinsure.info - United States
freesafesurf.info - United States
sacredtunnel.info - United States
greasyproxy.info - United States
dearproxy.info - United States
harshproxy.info - United States
wholebypass.info - United States
netwideopen.com - United States
unblockthe.info - United States
sandbypass.info - United States
secureproxi.info - United States
stupidteacher.info - United States
hidefrom.com - United States
freeurip.com - United States
15 Non-US Proxy Servers
tradeadspace.info - Canada
tissi.net.br - Brazil
proxysimple.info - France
quickprox.info - Great Britain (UK)
reldy.com - Germany
go-fish.info - Singapore
thebestwebsearch.com - Canada
jand0wn.info - Canada
totalsecure.info - Great Britain (UK)
cinipac.net - Estonia
Wednesday, April 20, 2011
Query to find all the tables and columns in selected database
In this case we can take help of SysObjects, SysColumns, SysTypes tables of SQL Server 2005. These tables stores the information about each tables and columns and their data types. Using this tables you can write the query to find out all the tables and columns in selected database. Below is the query that gives you all the table and columns for those tables with data types and length.
SELECT
SysObjects.[Name] as TableName,
SysColumns.[Name] as ColumnName,
SysTypes.[Name] As DataType,
SysColumns.[Length] As Length
FROM
SysObjects INNER JOIN SysColumns
ON SysObjects.[Id] = SysColumns.[Id]
INNER JOIN SysTypes
ON SysTypes.[xtype] = SysColumns.[xtype]
WHERE
SysObjects.[Type]='U'
ORDER BY
SysObjects.[Name]
“Type” columns of SysObjects table represent the different objects available in database (like Table,Trigger,Stored Procedures etc.). Below list explains the different values of “Type” columns.
C = CHECK constraint
D = Default or DEFAULT constraint
F = FOREIGN KEY constraint
FN = Scalar function
IF = Inlined table-function
K = PRIMARY KEY or UNIQUE constraint
L = Log
P = Stored procedure
R = Rule
RF = Replication filter stored procedure
S = System table
TF = Table function
TR = Trigger
U = User table
V = View
X = Extended stored procedure
For more detail refer SysObjects and SysColumns. and So in fig – (1) query uses [type] = ‘U’. This means query displays al the user tables. You can change the condition in WHERE clause to get different objects. The query shown below displays all the triggers in selected database.
SELECT
b.[Name] as [Table Name],
a.[Name] as [Trigger Name],
a.[crdate] as [Created Date]
FROM
SysObjects a INNER JOIN Sysobjects b
ON a.[parent_obj] = b.[id]
WHERE
a.[type] = 'TR'
ORDER BY
b.[Name]
Happy Programming !!!!
Wednesday, April 6, 2011
Import Excel Spreadsheet Data into SQL Server Database Table Using SqlBulkCopy
AppSettings :
add key="Excel2003SqlConnection" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties="Excel 8.0;HDR=YES;IMEX=1"">
add key="Excel2007SqlDBConnection" value="Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties="Excel 12.0 Xml;HDR=YES;IMEX=1"">
add key="FileUploadLocation" value="~/ExcelFilesUploaded/Temp"/>
Funtction to Upload Excel Files:
public void UploadExcelFileToDataBase(string DestServer, string DestDatabase, string DestUserID, string DestPassword, string destinationtableName, string ExcelSheetRange,FileUpload fileUpload1,Label label1)
{
try
{
if (fileUpload1.HasFile)
{
//the location is given in the web.config file's Appsettings.
string SaveLocation = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["FileUploadLocation"]);
string location = SaveLocation + fileUpload1.FileName;
fileUpload1.SaveAs(location);
string xConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source= " + location + ";" + "Extended Properties=Excel 8.0;";
using (OleDbConnection connection = new OleDbConnection(xConnStr))
{
OleDbCommand command = new OleDbCommand("Select * FROM " + ExcelSheetRange + "", connection);
connection.Open();
//delete all previous records from the table.
SQLHelper objSql = new SQLHelper();
objSql.SqlText = "Delete from " + destinationtableName;
objSql.ExecuteSql(false);
objSql.Close();
objSql.Dispose();
// Create DbDataReader to Data Worksheet
using (DbDataReader dr = command.ExecuteReader())
{
// SQL Server Connection String
string ConnString = "server = " + DestServer + "; database = " + DestDatabase + "; user id= " + DestUserID + ";password=" + DestPassword;
string sqlConnectionString = ConnString;
// Bulk Copy to SQL Server
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConnectionString))
{
bulkCopy.DestinationTableName = destinationtableName;
bulkCopy.WriteToServer(dr);
}
}
}
label1.Visible = true;
label1.Text = "Data Uploaded Successfully on " + destinationtableName;
}
}
catch (Exception ex)
{
label1.Text = ex.ToString();
}
}