Skip to main content

Posts

Tips to increase your Transact-SQL efficiency Part 1.

Given below are little known tips that you can use to ensure your Transact-SQL queries are performing in the  most efficient manner possible. 1. Avoid '*' in select query.      Restrict the queries result set by returning only the particular columns from the table and not all the  table's columns. The sql query becomes faster if you use the actual column names in SELECT  statement instead of than '*'. 2. Avoid COUNT(*) in select statement to check the existence of records in table.       Instead use IF EXISTS() to check records. - Write the query as: IF EXISTS (SELECT * FROM table_name WHERE column_name = ‘xxx’) - Instead of : SELECT COUNT(*) FROM table_name WHERE column_name = ‘xxx’ 3. Use alternate of SELECT COUNT(*).      Use an alternative way instead of the SELECT COUNT(*) statement to count the number     of records in  table.         - SELECT CO...

Importing the Excel into the Database (SQL).

We can import the excel into the Database by using the following query. Suppose we have a table named as Address_Temp and it has three column. 1. Name 2. State 3. Zip Here we need to update the zip code with the new value and to update that zip code we need to check the excel. So we can use that excel in our sql server by importing it using the following command. Its very easy query but make sure that it won't work in following two scenarios. 1. The file need to be in local machine. 2. The file should not be password protected. Declare @ ZipTemp NVarchar ( 255 ) set @ ZipTemp = ( SELECT * FROM OPENROWSET ( 'Microsoft.Jet.OLEDB.4.0' , 'Excel 8.0;Database=C:\Addresses.xls;IMEX=1' , 'SELECT top 1 ZIP FROM [Sheet1$] where ZIP = "328301"' ))

Simple Pyramid in Csharp .Net

    *   ***  ***** ******* Updated  As you can see below the code for simple pyramid has two for loop nested in each other. So for each row it enter, it increment the counter and draw the star against forming a pyramid like figure. You can use  different special counter, play with the loop and enjoy the coding. Simple Pyramid in Csharp    class Program     {          static void Main( string [] args)         {             int row, col = 0, n = 5;                                 for (row = 0; row <= n; row++)             {           ...

Rise, Fall and Struggle of Microsoft .Net [Article]

Some years ago there was a guy named Vinod Khosla from IIT- Delhi and Stanford. This awesome guy co-founded Sun Microsystem. Sun Microsystem as we all know is fully undertaken by Oracle. But Sun Microsystem came up with a fantastic language called Java. This language was becoming too famous and popular since its birth and by 90's its JAVA, JAVA and only JAVA everywhere. Microsoft who was struggling with the PC market at that time want's to capture the opportunity and Microsoft was building everything like the OS  and Office and Java was taking the credit of so called windows application so then MICROSOFT plans to launch its own language. Yes, so think back a decade or so ago. As you may recall, .Net was supposed to be much more than just the next version of Windows DNA or COM+ or COM. It was supposed to destroy Java, extend the Windows platform, and secure the Microsoft monopoly for another decade or two. But then what happened after the DOT COM BUBBLE. Rise Like m...

Send a Fax in windows using faxcomexlib and TAPI in VB code .Net

An application that provides sending fax from faxmodem, connected to the computer, will be explained in the following post.  We can use Telephony Application Programming Interface (TAPI) and the Fax Service Extended Component Object Model (COM) API to send fax. The fax service is a Telephony Application Programming Interface (TAPI)-compliant system service that allows users on a network to send and receive faxes from their desktop applications. The service is available on computers that are running Windows 2000 and later. The fax service provides the following features: Transmitting faxes Receiving faxes Flexible routing of inbound faxes Outbound routing Outgoing fax priorities Archiving sent and received faxes Server and device configuration management Client use of server devices for sending and receiving faxes Event logging Activity logging Delivery receipts Security permissions The following Microsoft Visual Basic code example sends a fax. Note that...

What is OOP ? Basic Concepts.

What is OOP? Object oriented programming is a type of programming paradigm based around programming classes and instances of classes called objects. These can be objects that appear on the screen (e.g., pictures, textboxes, etc.) or are part of the programming (e.g. actors, connections, particles, etc.) What is an Object? An object is merely a collection of related information and functionality. An object can be something that has a corresponding real-world manifestation (such as an employee object), something that has some virtual meaning (such as a window on the screen), or just some convenient abstraction within a program (a list of work to be done, for example). An object is composed of the data that describes the object and the operations that can be performed on the object. Information stored in an employee object, for example, might be various identification information (name, address), work information (job title, salary), and so on. The operations performed might include...

Three Tier Architecture : A simple Example/Illustration

Three Tier Architecture: Very Easy to understand, the three tier are: 1. Presentation layer 2. Business Layer 3. Database Layer Simple Example: Lets take example of a Songs and Artist. 1. DataAccess Layer Below is a class of Data Access Layer, that has some dummy/fudge data, we only write DataBase calling method in DataAccessLayer. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DataBaseLayer {     public class DataAccessLayer     {         string [] ArtistName = { "Akon" , "Shakira" , "Michael_Jackson" };         string [] Shakira = { "Waka Waka" , "Addicted to you" , "Beautiful Liar" };         string [] Akon = { "Chammak Challo" , "Lonely" , "Dont Matter" };         string [] Michael_Jackson = { "Beat It" , "Danger...