Convert Rows to Columns in SQL Server Without Using Pivot

Convert Rows to Columns in SQL Server Without Using Pivot DECLARE @UserData TABLE (UserName VARCHAR(50),Mobile VARCHAR(50)) INSERT INTO @UserData VALUES ('Abdul',23243434) INSERT INTO @UserData VALUES ('Abdul',345435345) INSERT INTO @UserData VALUES ('Abdul',23423) INSERT INTO @UserData VALUES ('Raj',2345435) INSERT INTO @UserData VALUES ('Raj',324324) INSERT INTO @UserData VALUES ('Raj',234234) INSERT INTO @UserData VALUES ('Manish',3453453) INSERT INTO @UserData VALUES ('Manish',345345) INSERT INTO @UserData VALUES ('Manish',23452) ;WITH UserMaster AS (   SELECT *,ROW_NUMBER() OVER(PARTITION BY UserName ORDER BY UserName) AS ColumnNumber FROM @UserData ) SELECT DISTINCT t.UserName ,t1.Mobile AS website1,t2.Mobile AS website2,t3.Mobile AS website3…

Drop index from Table

To remove index from table we use drop index statement in sql server. To create index on column in sql server that syntax will be like as shown below Syntax to Create Index CREATE INDEX indexname ON Tablename(columnname)

Difference between Cursor and While Loop with Example

Here I will explain difference between cursor and while loop in sql server with example or explain cursor vs while loop with example in sql server. Cursors in sql server allow you to fetch a set of data, loop through each record, and modify the values as necessary; then, you can easily assign these values to variables and perform processing on these values. While loop also same as cursor to fetch set of data and process each row in sql server.

CasCading DropDownList using Generic Handler and JQuery in Asp.net

ometimes we need to do fill dropdownlist using JQuery and Generic Handler in Asp.net Explanation given below: Design Page: SELECT YOUR STATE Generic Handler: public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; int id = Convert.ToInt32(context.Request["id"]); string sJSON = GetProduct(id); context.Response.Write(sJSON); } public string GetProduct(int id)

Database Normalization Tutorial with example

Normalization is the process of efficiently organizing data in a database. There are two goals of the normalization process: eliminating redundant data (for example, storing the same data in more than one table) and ensuring data dependencies make sense (only storing related data in a table). Both of these are worthy goals as they reduce the amount of space a database consumes and ensure that data is logically stored. Database normalization is the process of organizing the fields and tables of a relational database to minimize redudancy and dependency. Normalization usually involves dividing large tables into smaller (and less redundant) tables and defining relationships between them. The objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database using the defined relationships. Normalization is a process of simplifying the relationship between the data in a record it is carried out for the following reasons. To simplifying the maintenance of data through updates, insertion and deletions To allow simple retrieval of data in response to query and requests To avoid restructuring of data when new application requirements arises. To structure the data so that any relationship can be easily represented

Difference Between Sql Server CHAR, VARCHAR and NVARCHAR Data Type

CHAR is a Fixed Length Data Type. For example if you declare a variable/column of CHAR (10) data type, then it will always take 10 bytes irrespective of whether you are storing 1 character or 10 character in this variable or column. And in this example as we have declared this variable/column as CHAR(10), so we can store max 10 characters in this column. OR It stores fixed length of character. if you declare char(50) then it allocates memory for 50 characters. if you store 10 character word then it store it in 10 characters memory location and other 40 character's memory location will be wasted. Char datatype can store upto 8000 bytes of fixed-length character. VARCHAR is a variable length Data Type. For example if you declare a variable/column of VARCHAR (10) data type, it will take the no. of bytes equal to the number of characters stored in this column. So, in this variable/column if you are storing only one character then it will take only one byte and if we are storing 10 characters then it will take 10 bytes. And in this example as we have declared this variable/column as VARCHAR (10), so we can store max 10 characters in this column.