Calling one stored procedure within another stored procedure in sql

In this article we will learn how to call one stored procedure within another stored procedure in sql. Its quite easier and you don't have to bear any pain to do this. Lets have a look into example given below
declare @studentid bigint
declare @studentname varchar(50) 
set @studentid=20832083
exec @studentname = Web_Proc_GetStudentName @studentid -- use comma to separate multiple parameters 
exec @studentname = Web_Proc_GetStudentName @studentid

The above mentioned line of code is assigning return value of a stored procedure to @studentname variable. So folks that's it. Hope so this article will be proved handy for you.

Stay tuned for more useful tutorials.
Read more...

Get page load time in asp.net using c#

In this article, i will tell you guys how to get page load time. I have a web form that name is getloadtime.aspx, lets suppose there is lot of code written in it due to that its loading speed is very slow, to calculate the load time following code snippet will be used.

getloadtime.aspx.cs

    DateTime ServerStartTime;
    DateTime ServerEndTime;

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected override void OnPreInit(EventArgs e)
    {
        ServerStartTime = DateTime.Now;
        base.OnPreInit(e);
    }

    protected override void OnLoadComplete(EventArgs e)
    {

        ServerEndTime = DateTime.Now;
        TrackPageTime();//It will give you page load time
    }


    public void TrackPageTime()
    {
        TimeSpan serverTimeDiff = ServerEndTime.Subtract(ServerStartTime);
    }


I hope this article will be proved very handy for you people. Enjoy your work, enjoy coding.
Read more...

Problem while exporting numeric data from ms sql server 2008 to excel

In this article i am discussing a problem with you guys that i faced today. Today i run a query in ms sql server 2008 management studio, query was basically giving the following records from student table

  1. Registration_Number
  2. First_Name
  3. Last_Name
  4. Email_Address
Query was

SELECT REGISTRATION_NUMBER,LAST_NAME,FIRST_NAME,EMAIL FROM STUDENT 
ORDER BY FIRST_NAME

Problem was with Registration_Number column, in table its data type was bigint. When i run the that query, copy the result set and then paste into excel then Registration_Number column was giving two problems, mentioned below
  1. Some of registration numbers were in unwanted data type for me such as floating type. I had a registration number 1010512500100483 which was showing as 1.01051E+15
  2. Secondly, some registration numbers were automatically rounded off, such as 1010512500100505 was rounded into 1010512500100500, moreover in excel it was showing as 1.01051E+15 but when I clicked on the cell then it was showing in address bar as 1010512500100500 instead of 1010512500100505
Now we have two solutions, first one is pretty simple in which your excel cell should have been formatted as text before you pasting the result set. 

Before telling you second and accurate solution, let me tell you methods that i adopt in order to paste the actual result set from sql server to excel without changing the cell data type in excel. 

Methods that i adopt and all were proved fail. 

I converted the data type of registration_number column from bigint to varchar as mentioned below but it was not working.
SELECT CONVERT(VARCHAR,REGISTRATION_NUMBER) AS REGISTRATION_NUMBER,LAST_NAME,FIRST_NAME,EMAIL FROM STUDENT 
ORDER BY FIRST_NAME 
I converted the datatype of registration_number column from bigint to varchar and concatenated space as mentioned below but it was not working.
SELECT CONVERT(VARCHAR,REGISTRATION_NUMBER)+' ' AS REGISTRATION_NUMBER,LAST_NAME,FIRST_NAME,EMAIL FROM STUDENT 
ORDER BY FIRST_NAME 
But the following query proved successful as i achieved my target which was copying the query result set and pasting it into excel sheet without formatting any excel cell.
SELECT CONVERT(VARCHAR,REGISTRATION_NUMBER)+CHAR(160) AS REGISTRATION_NUMBER,LAST_NAME,FIRST_NAME,EMAIL FROM STUDENT 
ORDER BY FIRST_NAME 
That's it. Cheers!!!
Read more...

Unable To Drag and Drop Stored Procedure onto dbml Designer

In this article we will discuss about a problem that i faced couple of days ago, my visual studio 2010 was working fine, i closed the visual studio and after some time when i reopened it and try to drag and drop the stored procedure then it didn't allow me to drag and drop the stored procedure.
I tried my level best to reset the settings of visual studio but got no success then by searching on internet i got the solution and the solution is pretty simple, I found that it is due to one of the dll file (dsref80.dll) of visual studio, the dll was corrupted so i straight away took that dll from one of my colleague and replace it

Path to replace the dll is shown below:

C:\Program Files\Common Files\Microsoft Shared\Visual Database Tools\dsref80.dll


Cheerz...! :) 
Read more...