Loading ...

Who is online?  0 guests and 0 members
home  »  blogs  »  Ajit Gupta

Communifire Blogs

Ajit Gupta : Most Recent postings

Ajit Gupta

Value type vs Reference type in C#

11/9/2009 by Ajit Gupta · 0 · 2514

Value types are allocated on the stack , while all reference types are allocated on the heap . A value type contains the actual value. A reference type contains a reference to the value. When a value type is assigned to another value type, it is copied. When a reference type is assigned to another reference type, a reference is assigned to the value. As you can see in below example: usin...

Ajit Gupta

How to show hierarchies of childs by using SQL Serve

10/5/2009 by Ajit Gupta · 1 · 1521

First I create a table Create Table ParentChild_Table (ID int identity(100,1),[Name]varchar(100),ParentID int) Then insert some records INSERT INTO ParentChild_Table VALUES('JOHN',0) INSERT INTO ParentChild_Table VALUES ('RINA',100) INSERT INTO ParentChild_Table VALUES ('RAJU',100) INSERT INTO ParentChild_Table VALUES ('RAJEEV',101) INSERT INTO ParentChild_Table VALUES ('RAVI',103) INSER...

Ajit Gupta

How to generate alpha numeric id in Sql Server database?

8/25/2009 by Ajit Gupta · 0 · 4579

This blog explain how to create alpha numeric id in sql server for this I’m going to create a Table with two columns . CREATE TABLE USER_DATA ([ID] NVARCHAR(10),[NAME] NVARCHAR(50)) Then create a stored procedure for insertion id and name in table here we pass name as parameter alpha numeric id will be generate by code like RP001,RP002 etc. CREATE PROC SP_INSERT_USER @NAME VARCHAR(50) AS...

Ajit Gupta

SET NOCOUNT in sql server

7/10/2009 by Ajit Gupta · 0 · 2685

It stops the message that shows the count of the number of rows affected by a Transact-SQL statement or stored procedure from being returned as part of the result set. Syntax SET NOCOUNT { ON | OFF } for example set nocount on select * from Table here message displayed Command(s) completed successfully. if we don't Set NOCOUNT on then message displayed (n row(s) affected) here n could be...

Ajit Gupta

Temp Tables vs Table Variables in sql server

7/10/2009 by Ajit Gupta · 1 · 18858

When writing SQL code, you often need a table in which to store data temporarily when it comes time to execute that code. You have three table options: local temporary tables, global temporary tables and table variables. I'll discuss the differences between using temporary tables in SQL Server versus table variables. Temporary Tables Both local and global temporary tables are physical ta...

Ajit Gupta

Selecting duplicate rows from a table in sql server

7/2/2009 by Ajit Gupta · 0 · 3170

This example shows on how to get all duplicate rows from a table for this I’m going to create a Table with two column and inserting some distinct & duplicate rows in it and then write query to display all duplicate records . Step1: CREATE TABLE Employ_Salary_Record ( EmployeeName Nvarchar(50) , Salary int) Step2: Insert into Employ_Salary_Record values('a1',11000) Insert into Employ_...

Ajit Gupta

out vs ref parameter in c#

7/1/2009 by Ajit Gupta · 1 · 4970

Even the variable passed as out parameter is similar to ref but there are few implementation differences.Argument passed as ref must be initialized before it is passed to the method, where as in case of out its is not necessary. out parameter can be used when we want to return more than one value from a method. To illustrate, below programs shows how to pass agrument via out and ref : us...

Ajit Gupta

Delegate in c#

7/1/2009 by Ajit Gupta · 0 · 1969

“Delegate is a method template which used to implement the concept of function pointer.” A Delegate is a special type of user-defined variable that define globally ,like a class.In fact ,a delegate is created like a interface but as a method .Based on this ,a delegate provide a template for method ,like an interface provide template for class. like an interface delegate is not defined. D...

Ajit Gupta

Classes vs Structs

6/30/2009 by Ajit Gupta · 0 · 913

Classes vs Structs Structs differ from classes in the way that they are stored in memory and accessed (classes are reference types stored in the heap, structs are value types stored on the stack), and in some of the features (for example, structs don’t support inheritance). You will tend to use structs for smaller data types for performance reasons. class PhoneCustomer { public const str...

Ajit Gupta

Property in c#

6/30/2009 by Ajit Gupta · 0 · 1094

The idea of a property is that it is a method or pair of methods that are dressed to look like a field as far as any client code is concerned. A good example of this is the Height property of a Windows Form. "Properties can be thought as virtual fields." Example Public int Age { Get { Return this.age; } Set { this.age=value; } } Person.Age=4;

Ajit Gupta

INDEXER in C#

6/30/2009 by Ajit Gupta · 0 · 1491

“An Indexer is a member that enables object to be indexed in a the same way as array.” Indexers are used for treating an object as an array. The indexers are usually known as smart arrays in C# community. Defining a indexer is much like defining properties. We can say that an indexer is a member that enables an object to be indexed in the same way as an array. Syntax of Indexer this [arg...

Ajit Gupta

Difference between #temp and ##temp(temporary tables) in sql server

6/21/2009 by Ajit Gupta · 0 · 5504

The two types of temporary tables, local and global, differ from each other in their names, their visibility, and their availability. Local temporary tables have a single number sign (#) as the first character of their names; they are visible only to the current connection for the user; and they are deleted when the user disconnects from instances . Global temporary tables have two numbe...

Ajit Gupta

Transactions in SQL Server

6/21/2009 by Ajit Gupta · 0 · 705

Transactions group a set of tasks into a single execution unit. Each transaction begins with a specific task and ends when all the tasks in the group successfully complete. If any of the tasks fails, the transaction fails. Therefore, a transaction has only two results: success or failure. Incomplete steps result in the failure of the transaction. Users can group two or more Transact-SQL ...

Ajit Gupta

Difference between UNION and UNION ALL in sql server

6/21/2009 by Ajit Gupta · 0 · 1983

Union will filter duplicate values where as union all will not filter duplicate values. The difference between UNION ALL and UNION is that, while UNION only selects distinct values, UNION ALL selects all values. for understanding more deeply see bellow example . select 'Ajit','Gurgaon' union all select 'Monu','Guraon' union all select 'vinay','Noida' union all select 'Ajit','Gurgaon the ...

Ajit Gupta

Stored procedures versus user defined function in sql server.

6/21/2009 by Ajit Gupta · 1 · 852

Procedure can return zero or n values whereas function can return one value which is mandatory. Procedures can have input,output parameters for it whereas functions can have only input parameters. Procedure allow select as well as DML statement(Create,Drop,Alter) in it whereas function allow only select statement in it. Functions can be called from procedure whereas procedures cannot be ...

Ajit Gupta

Difference between Identity() and @@identity in sql server?

6/17/2009 by Ajit Gupta · 0 · 952

IDENTITY (Property) It Creates an identity column in a table. This property is used with the CREATE TABLE and ALTER TABLE Transact-SQL statements. Syntax IDENTITY [ ( seed , increment ) ] Example create table Mytable ( Identity_Id int identity(1001,1),name varchar(50),city varchar(50) ) @@IDENTITY :- Returns the last-inserted identity value. Syntax SELECT @@IDENTITY AS IDs example select...

Page 1 of 1 (16 items)

Product Spotlight

ASP.NET Hosting Spotlight

Join CodeAsp.Net for FREE Today!

It's fast, easy and free! Submit articles, get your own blog, ask questions & give answers in the forums, and become a better developer, faster.

enter your email address:

 

Quick Vote

What kind of email newsletter would you prefer to receive from CodeAsp.Net?