Wednesday, 17 September 2014

Main frequently asked interview questions in SQL Server

In this article I will explain How to get stored procedure list in SQL Server? , How to get Tables list in SQL Server? , how to get list of views in SQL Server?

The main frequently asked interview questions in SQL Server are

1.      How to get stored procedure list in SQL Server?
2.      How to get Tables list in SQL Server?
3.      How to get list of views in SQL Server?

Below queries are useful for getting the Stored Procedure list in SQL Server: 4 ways to get the Stored Procedure list

1.   select *   from DataBaseName.information_schema.routines  where routine_type =                              'PROCEDURE'


2.      select *  from information_schema.routines  where routine_type = 'PROCEDURE'


3.      select *   from DataBaseName.information_schema.routines  where routine_type = 'PROCEDURE'    and Left(Routine_Name, 3) NOT IN ('sp_', 'xp_', 'ms_')

4.      SELECT name,   type  FROM dbo.sysobjects WHERE (type = 'P')


Below query is useful for getting the Views list in SQL Server:


SELECT * FROM sys.views


Below queries are useful for getting the SQL Tables list:

SQL Server 2005 or 2008 and above:

SELECT * FROM information_schema.tables

SQL Server 2000:

SELECT * FROM sysobjects WHERE xtype='U'





How to get Tables list in SQL Server? , how to get stored procedure list in SQL Server? , how to get list of views in SQL Server?

In this article I will explain How to get Tables list in SQL Server? , how to get stored procedure list in SQLServer? , how to get list of views in SQL Server?

Below queries are useful for getting the SQL Tables list:

SQL Server 2005 or 2008 and above:

SELECT * FROM information_schema.tables

SQL Server 2000:

SELECT * FROM sysobjects WHERE xtype='U'

Below queries are useful for getting the Stored Procedure list in SQL Server: 4 ways to get the Stored Procedure list

1.      select *  from information_schema.routines  where routine_type = 'PROCEDURE'

2.   select *   from DataBaseName.information_schema.routines  where routine_type =                              'PROCEDURE'

3.      select *   from DataBaseName.information_schema.routines  where routine_type = 'PROCEDURE'    and Left(Routine_Name, 3) NOT IN ('sp_', 'xp_', 'ms_')

4.      SELECT name,   type  FROM dbo.sysobjects WHERE (type = 'P')

Below query is useful for getting the Views list in SQL Server:


SELECT * FROM sys.views



How to Identify GridView EmptyDataTemplate in JavaScript using ASP.NET. (OR) How to calculate GridView EmptyDataTemplate Textbox values in JavaScript using ASP.NET

In this article I will explain how to Identify GridView EmptyDataTemplate in JavaScript using ASP.NET.

(OR)

How to calculate GridView EmptyDataTemplate Textbox values in JavaScript using ASP.NET

I have created GridView with Empty data template. I want to calculate data dynamically at the data entry time. If the end user enter the Quantity, Rate, TaxAmt after automatically calculate and update the Amount column.

Below is the sample code for design of GridView

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" ShowFooter="true"  Width="100%" >
                                              
              <EmptyDataTemplate>
                                                    <table border="1">
                                                        <tr>                                                           
                                                            <td>Quantity
                                                            </td>
                                                            <td>Rate
                                                           </td>
                                                            <td>TaxAmt
                                                            </td>
                                                            <td>Amount
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                               
                                                            <td Width="10%">
                                                                <asp:TextBox runat="server" ID="txtQuantityEDT" Width="90%" onblur="ValidateGridEmptyTemp();" ></asp:TextBox>
                                                            </td>
                                                            <td Width="10%">
                                                                <asp:TextBox runat="server" ID="txtRateEDT" Width="90%"  onblur="ValidateGridEmptyTemp();"></asp:TextBox>
                                                            </td>
                                                            <td Width="10%">
                                                                <asp:TextBox runat="server" ID="txtTaxAmtEDT" Width="90%" onblur="ValidateGridEmptyTemp();"></asp:TextBox>
                                                            </td>
                                                            <td Width="10%">
                                                                <asp:TextBox runat="server" ID="txtAmountEDT" Width="90%" onblur="ValidateGridEmptyTemp();"></asp:TextBox>
                                                                
                                                            </td>
                                                        </tr>
                                                    </table>
                     </EmptyDataTemplate>
  </asp:GridView>


Below is the JavaScript code for Dynamic empty data template calculation.

function ValidateGridEmptyTemp() {

            var txtName = document.getElementById('<%=((TextBox)GridView1.Controls[0].Controls[0].FindControl("txtQuantityEDT")).ClientID %>');
            var Quantity = document.getElementById('<%=((TextBox)GridView1.Controls[0].Controls[0].FindControl("txtRateEDT")).ClientID %>');
            var Bill = document.getElementById('<%=((TextBox)GridView1.Controls[0].Controls[0].FindControl("txtTaxAmtEDT")).ClientID %>');

            var Final = Number(txtName.value * Quantity.value) + Number(Bill.value);

            document.getElementById('<%=((TextBox)GridView1.Controls[0].Controls[0].FindControl("txtTaxAmtEDT")).ClientID %>').value = Final;

        }

How to disable backspace in textbox using JavaScript in ASP.NET

In this article I will explain How to disable backspace except textbox using JavaScript in ASP.NET.

(Or)

How to disable backspace in textbox using JavaScript in ASP.NET

I designed the ASPX page. In that page I declared one textbox, Textbox not allowed backspace.
Below is sample code for textbox design. Here we can use onKeyDown event for disable back button code.

<asp:TextBox runat="server" ID="txtPODate" Width="200px"
                                        onKeyDown="preventBackspace();"></asp:TextBox>

Below is the sample JavaScript code for disable Back Button.

function preventBackspace(e) {
            var evt = e || window.event;
            if (evt) {
                var keyCode = evt.charCode || evt.keyCode;
                if (keyCode === 8) {
                    if (evt.preventDefault) {
                        evt.preventDefault();
                    } else {
                        evt.returnValue = false;
                    }
                }
            }

        }

How to move cursor from left to right and right to left same as top to bottom and bottom to top on GridView Textboxes in C#.NET , ASP.NET.

In this article I will explain How to move cursor from left to right and right to left same as top to bottom and bottom to top on GridView Textboxes in C#.NET , ASP.NET , JavaScript.

(OR)

GridView Textboxes cursor moving from left to right and right to left same as top to bottom and bottom to top in C#.NET , ASP.NET , JavaScript.

(OR)

Left to right and right to left same as top to bottom and bottom to top cursor moving in GridView Textboxes C#.NET , ASP.NET , JavaScript.

    
  First we have to design the GridView page. Then go to GridView properties, double click on DataBound event. Copy the below code and paste it in to your c# page.