Skip to main content

Posts

Swapping two integer values in C# [Interview Question]

Offlate, many of my friends where talking about this problem. It seems they ask this question frequently in Microsoft Interviews :) I remember asking this question to freshers in 2005! Just thought I would refresh my knowledge also on this :) So here are few samples which I tried for your reference. Method 1: Using intermediate temp variable int intNumOne = 1, intNumTwo = 2; int intTempVariable; //Swapping of numbers starts here intTempVariable = intNumOne; intNumOne = intNumTwo; intNumTwo = intTempVariable; Response.Write("Value of First Variable :: " + intNumOne.ToString() + "<br>"); Response.Write("Value of Second Variable :: " + intNumTwo.ToString() + "<br>"); Method 2: Without using Temp Variable and by using 8th standard Mathematics :) int intNumOne = 11, intNumTwo = 22; //Swapping of numbers starts here intNumOne = intNumOne + intNumTwo; intNumTwo = intNumOne - intNumTwo; intNumOne = intNumOne - intNumTwo; Response.Write(...

Different Types of Partitioning Operations in SQL Server 2005

In this post let me explain about the three different types of Operations one can do with Partitions. They are: 1. Split Partition 2. Merge Partition 3. Switch Partition (Important of the lot) Before reading further, make sure that you have read my earlier posts. That is, this and this . Split Partition For splitting a partition we need to make use of “Alter Partition Function” syntax. So in our existing “Partition function” lets create a new range with boundary value “Jan 01, 1970”. Alter Partition Function PF_DOB_Range() Split Range ('01-01-1970') Now if we execute this code snippet it would throw an error something like this: Msg 7707, Level 16, State 1, Line 1 The associated partition function 'PF_DOB_Range' generates more partitions than there are file groups mentioned in the scheme 'PS_DOB_1'. So the way to split a partition is: Step 1: Create a new Filegroup (if at all already you don’t have an extra filegroup) Step 2: Make use of that Filegroup while al...

Example for Creating and using Partitions in SQL Server 2005

Lets assume that we have table which contains records of our company transaction starting from the date when our company was started 15 years ago! Hope you would understand that the table would have hell a lot of data as it would be holding 15 years of data. But effectively we might be using only last 2 months or 1 year data at the max (very frequently). For each query, it would be processing through this huge data. Bottomline as the table grows larger the performance would go for a toss, also scalabiity and managing data would also be difficult. Hope I have made the point clear. With the help of partitioning a table we can achieve a great level of performance; also managing tables easier. In our case, one of the way to increase the performance would be to “Partition” the data on a yearly basis and stored on a different filegroup (SQL 2005 allows you to partition tables based on specific data usage patterns using defined ranges or lists). For further theoritical knowledge on this subje...

App_offline.htm – ASP.NET 2.0 new feature

It’s an interesting find. I got few mails asking me suggestions on the way to handle situations where “the application needs to be updated with the latest code base”. I was preparing a blog post something like this: 1. Normally sites are deployed in Web farm scenarios. If your app is also deployed in a web farm then it’s better to bring one server down update the code base there while all the user request would be served by the other servers in the farm. This way the downtime of the application would be almost zero. 2. If at all your application is deployed on a single server then either you need to face the downtime :) or temporarily create another virtual directory with the old code base. This Virtual directory would be functional till the time you update the actual directory with your latest code base. There would be some negligible amount of downtime here. 3. If you can’t create a new virtual directory for some reason! Then create a static page (“SiteDownForMaintanance.htm”) and ba...

Time to say, Goodbye to Adobe PDF Reader!

PDF (Portable Document Format) reader is a very important software one needs. As now-a-days most of the product user manual, eBooks, visa application forms etc., are in PDF format. Today’s computers almost always come with Adobe PDF reader installed by default. Till few weeks back I was also using it without much satisfaction!! No doubt Adobe PDF reader is a great product but I hate it for the following points: 1. I feel that Adobe PDF reader software is really bulky. 2. Loading time of PDF document is unnecessary in Adobe reader 3. Installation of Adobe PDF reader takes at least >= 5 minutes. For past few weeks I am fiddling with another PDF reader called “ Foxit Reader 2.0 ”. In my experience with this new reader, I haven’t found any of the above mentioned disadvantages which I have with Adobe PDF reader . Let me explain those 4 points in detail now: i) I feel that Adobe PDF reader software is really bulky. First of all downloading Adobe PDF reader isn’t an easy joke :) it takes ...

IndiMix '06 -- Webcast

In continuation to my previous post on IndiMix I got registered to the webcast couple of days back. I have gone through the agenda of the seminar and was interested only in these two sessions. 1. The Genesis of Creativity and Innovation – The Next Web Now (10:15 AM to 11:15 AM) Speaker: Steve Ballmer , CEO, Microsoft Corporation. 2. Designing for the Next Web Now – Experiences and Expressions that Capture the Imagination (2 PM to 3:15 PM). Speaker: i) Leon Brown , Regional Designer and User Experience Lead, Microsoft Corporation APAC (Singapore) ii) Pandurang Nayak , Developer Evangelist, Microsoft Corporation India iii) Deepak Gulati , Developer Evangelist, Microsoft Corporation India iv) Dax Pandhi , CEO, Nukeation Studios Not that I wasn't interested in the other sessions. Since that I am in vacation and browsing from home, I wanted to keep my broadband usage to the minimum :) Today Morning, when i tried accessing the URL (which they have sent me in the registration confirmatio...

I am one of the Microsoft BlogStar Winner :)

Wow I am really excited to know that i am one among the Top 20 Microsoft India BlogStar winners :) Check out http://www.microsoft.com/india/blogstars/winners.aspx On the flipside, I am bit disappointed that I didn't make it to the Top 5 :( Because the Top 5 guys gets a chance to meet Steve Ballmer in Mumbai tomorrow. But overall this Month seems to be a really good one to me :) Because starting from November 1st, 2006 till date i have got 3 awards/gifts (including this) from various technology related sites. The other two are: 1. I have won the first prize in community-credit website this month. 2. I have won the " Best Member Award " in dotnetspider. Technorati tags: Microsoft , Steve Ballmer

Visual Studio 2005 Tools for Office Second Edition

Visual Studio 2005 Tools for the 2007 Microsoft Office System (Visual Studio 2005 Tools for Office Second Edition or VSTO 2005 SE for short) is a free add-on to Visual Studio 2005 that empowers developers to build applications targeting the 2007 Office system. Developers can now harness the benefits of the 2007 Office system platform and create Office-based solutions using the professional development environment of Visual Studio 2005. Go through http://msdn.microsoft.com/office/tool/vsto/2005SE/default.aspx to know about the "Feature List", "Download links", "Demos - Video" and "Artiles" on this product.

SQL Server Health and History Tool

The Microsoft SQL Server Health and History Tool (SQLH2) allows you to collect information from instances of SQL Server, store this information, and run reports against the data in order to determine how SQL Server is being used. This version of SQLH2 supports SQL Server 2005 RTM collection.SQLH2 collects four main types of information: 1. Feature Usage – What services/features are installed, running and level of workload on the service. 2. Configuration Settings – Machine, OS and SQL configuration settings, SQL instance and database metadata. 3. Uptime of the SQL Server service 4. Performance Counters (optional) – Used to determine performance trends You can download this tool here Technorati tags: SQL Server 2005

SQL Server Hosting Toolkit Launched

The Database Publishing Wizard enables the deployment of SQL Server 2005 databases into a hosted environment on either a SQL Server 2000 or 2005 server. It generates a SQL script file which can be used to recreate the database in shared hosting environments where the only connectivity to a server is through a web-based control panel with a scripting window. The Database Publishing Wizard is currently a command line tool, though future releases will add a graphical user interface. 1. Current Release 2. Command Line Interface 3. Supported Objects & Types 4. Known Issues 5. Roadmap for Future Releases 6. FAQ 7. Tutorial: Upload the TimeTracker ASP.NET starter kit to your hosted account Source: codeplex Technorati tags: SQL Server 2005

Won a prize (Best Member Award) in dotnetspider.com

Below is the extract of the mail which I got from Tony John of dotnetspider.com couple of days back. Vadivel Mohanakrishnan, We are glad to inform you that you are selected as the RapTier Gift winner for the month of October 2006 for your valuable contributions to dotnetspider.com . We are looking forward to see more contributions from you in future. Winners list is here :: http://www.dotnetspider.com/gifts/Winners.aspx Gift which I would be getting is called "RapTier Software" . RapTier is a template-based ASP.NET, C#, VB.NET and SQL code generator that creates robust database driven applications for a wide range of database. Features: ASP.NET, C#, VB.NET and SQL code generation; DataSet and Typed Data Transfer Object support; Stored Procedure and Dynamic SQL support; Existing stored procedure wrapping; Support of many database engines; Template-based design, WebForm UI generation, Database documentation generation To know more about it, check this out http://www.sharppower....

Won the first prize in community credit ...

I am glad that few minutes back i came to know that I have won the 1st prize in Community-credit for the month of October 2006. Below is the extract from the mail which I received from David (Admin of Community-credit site). Hello Vadivel, Congratulations. You won 1st Prize in the October 2006 Contest. As you may know, a lot of people competed, but only a few won. Nicely done! Please also keep in mind that your prize is not just a stupid, geeky gift, but it's also a symbol to represent your contributions to the development community. When folks ask you how you won, you can tell them that it was by helping out other geeks. Be proud and brag. Check out this page to know about the Prize I got :: http://www.community-credit.com/CommunityCreditPrizePage.aspx and choose October 2006 in the dropdown.

Copying Database Diagram from DB server to another ...

For some, working with Databases is fun and for others, it could possibly be a nightmare. Understanding the structure of a Database schema from the available documentation could spell doom for many developers. A picture is worth a thousand words. This golden saying applies aptly to Databases! Yes, often, a pictorial representation of a Database conveys more meaning about the Database Schema than the SQL scripts generated or other documentation that may be available. One of the first thing developers wants to do when starting work on a new project is to understand the Database schema. Sometimes, understanding a complex database schema can be simplified largely by a relationship diagram. The Database diagram tools in the SQL Server enable administrators and developers to create Database diagrams very easily. This article demonstrates an efficient way to move DB diagrams from one Database to another. We are going to use two sample Databases for this purpose. They are named PlayDB and Play...

Do you think I will make it?

Approximately 20-25 days back I came to know about Community-Credit site and I started participating in it actively. See the below screenshot to know where I stand. FYI, Lorenzo Barbieri is maintaining his lead from day 1. For the past 10+ days I am maintaining the second position and just 4 days left to know who is the winner of this month. Do you think I can make it to the top? Technorati tags: Community-credit

Listing / Dropping ALL stored procedures from a database in SQL Server 2005

This was the question asked by a member here http://www.dotnetspider.com/qa/ViewQuestion.aspx?QuestionId=59232 Though I have answered there itself, thought I would document it here also for future reference. I) List all Stored procedures in a database: Select * from sys.procedures where [type] = 'P' and is_ms_shipped = 0 and [name] not like 'sp[_]%diagram%' OR Select * from sys.objects where type='p' and is_ms_shipped=0 and [name] not like 'sp[_]%diagram%' Please note that I have added the 'NOT LIKE' part to get rid of stored procedures created during database installation. II) Delete all [user created] Stored procedures in a database: Select 'Drop Procedure ' + name from sys.procedures Where [type] = 'P' and is_ms_shipped = 0 and [name] not like 'sp[_]%diagram%' This would list down all the user defined Stored procedure as 'Drop Procedure procedureName' in the result pane. Just copy-paste it into the query window ...

Brief Theoretical Knowledge about Table Partitioning

1. Partitioning is fully depended on Filegroups. 2. Start table partitioning as early as possible. So that huge data movement can be avoided later. 3. A file would be grouped to one and only Filegroups. Actually Filegroups improves database maintenance, performance and Online restore. 4. For your information, default Filegroup is always “primary filegroup“. If at all you don’t believe me! Create a dummy table something like this, Create Table Test ( sno int ) Go Now in your SQL Mgmt Studio, right click on that table and check the properties yourself. 5. All “System Objects” have to belong to PRIMARY Filegroup. 6. It’s recommended, to have all “User Objects” created in another Filegroup. 7. In SQL Server 2000, any user object can’t belong to more than one Filegroup. But it’s possible now in SQL Server 2005. That is, a table data can be partitioned and stored into multiple Filegroups. 8. If you have two large tables, put them into different Filegroups. Filegroups are recommended being on...

Accessing a table in SQL Server 2005 (Schema related)

Recently in a discussion forum I came across this question "I have a small Doubt in SQL server. The database name is 'AdventureWorks' and the table name is 'Production.Culture'. What is the query to fetch records from that table." The answer to this is : Select cultureid, [name], modifiedDate from AdventureWorks.Production.Culture There was another member of the forum who was saying that we need to only use the below query: Select * from AdventureWorks. dbo.Production .Culture Please note that he has mentioned two Schema names (dbo and Production) in a single query. This query wouldn't work and I thought I would explain the concept of "Schemas" in SQL Server 2005 to him. In short, a) Schema is similar to Namespaces in .NET b) It helps in logical grouping of tables. c) To view all existing schema in a database, for example within AdventureWorksDB :: 1. Open ur SQL Mgmt studio 2. Go to AdventureWorks DB and expand it 3. Expand the Tables 4. Now jus...

Find out the Second (2nd) Highest Salary ...

For past 15 days I am actively participating in the discussion forums of dotnetspider. Yesterday there was a question relating to SQL Server which seems to be asked in interviews very often. i.e., How to find out the 2nd highest salary of an employee? Thought I would give out an sample for those who are yet to find an answer for this. For that purpose I have given a table structure with few sample records inserted to it. -- Table Structure Create table employee ( [Name] varchar(20), Sal int ) Go -- Populate Sample Records Insert into employee values ('Vadivel', 80000) Insert into employee values ('Vel', 70000) Insert into employee values ('xxx', 40000) Insert into employee values ('Sneha', 60000) The Solution: Select top 1 [Name], Sal from ( Select Top 2 [Name], Sal from employee order by Sal Desc ) AS A1 Order by Sal Technorati tags: SQL , Databases , SQL Server , SQL Server 2005

Desi Search Engine ...

Guruji.com - India's local search engine! has been launched in Bangalore on 12th of this month. The site seems to be focused on Indian consumers. May be they wanna become Google of India! I tried out few searches - the results and performance are really impressive. The search strings which i tried are as follows: 1. Pizza Adyar 2. Verizon Guindy Quite a few of my search strings also failed. Its understandable as they are still in Beta! But I feel its definitely a good start. Guys use it and share your experience .... If you like to know more about the Investors, Management Team etc., check out this. Extract from TechTree : Gaurav Mishra, co-founder and coo, guruji.com explains, "90% of Internet search queries are local in nature, and guruji.com will deliver better search results than any other search engine in these instances. For example, if a user types a search "Pizza in Koramangala, Bangalore " or "Chinese restaurant Juhu, Mumbai" the user will be able...