Skip to main content

Posts

Showing posts from December, 2014

OutPut Parameter in sql server

Output parameter sample in stored procedure and how to use the output parameter. USE [FruitsDB] GO /****** Object:  StoredProcedure [dbo].[GetFruitName]   *****/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[GetFruitName]  @FruitId INT,  @FruitName VARCHAR(30) OUTPUT AS BEGIN  SELECT @FruitName = FruitName  FROM Fruits  WHERE FruitId = @FruitId END In C# code:  using (SqlCommand cmd = new SqlCommand("GetFruitName", con))             {                 cmd.CommandType = CommandType.StoredProcedure;                 cmd.Parameters.AddWithValue("@FruitId", int.Parse(txtFruitId.Text.Trim()));                 cmd.Parameters.Add("@FruitName", SqlDbType.VarChar, 30);                 cmd.Parameters["@FruitName"].Direction = ParameterDirect...

Difference between Stored Procedure and Function in SQL Server

Difference between Stored Procedure and Function in SQL Server Stored Procedures are pre-compile objects which are compiled for first time and its compiled format is saved which executes (compiled code) whenever it is called. But Function is compiled and executed every time when it is called. For more about stored procedure and function refer the articles Different types of Stored Procedure and Different types of Function. Basic Difference 1.       Function must return a value but in Stored Procedure it is optional( Procedure can return zero or n values). 2.       Functions can have only input parameters for it whereas Procedures can have input/output parameters . 3.       Function takes one input parameter it is mandatory but Stored Procedure may take o to n input parameters.. 4.       Functions can be called from Procedure whereas Procedures cannot be called from Function. Adv...

Different Types of SQL Server Functions

Types of Function 1. System Defined Function These functions are defined by Sql Server for different purpose. We have two types of system defined function in Sql Server 1. Scalar Function Scalar functions operates on a single value and returns a single value. Below is the list of some useful Sql Server Scalar functions. System Scalar Function Scalar Function Description abs(-10.67) This returns absolute number of the given number means 10.67. rand(10) This will generate random number of 10 characters. round(17.56719,3) This will round off the given number to 3 places of decimal means 17.567 upper('dotnet') This will returns upper case of given string means 'DOTNET' lower('DOTNET') This will returns lower case of given string means 'dotnet' ltrim(' dotnet') This will remove the spaces from left hand side of 'dotnet' string. convert(int, 15.56) This will convert...

Do you know why MVC is better than ASP.NET?

Why MVC is better than ASP.NET? ASP.net is the old standard for web forms. I know ASP.net mvc is a newer framework. ASP.net MVC was created in 2007 or 2008. The model-view-controller pattern tries to separate data, logic and the presentation of both to the user. That's one of the basic things they teach you in computer science. When you separate these layers, you can change the view based on the user's input without altering the presentation. AKA, changing buttons and menu options on a user's screen without losing the data they've put in because that is saved somewhere other than the life cycle workflow ASP.net uses. MVC lets you execute part of the code on the client, lessening demand on the server. And, sometimes, increasing response time as a result of the local processing. I had not heard that it increased performance. It can, but doesn't always. But MVC always has easier integration with JavaScript frameworks. And MVC is the standard of the stateless web, since...