Sunday, August 31, 2014

If and Like with Stored Proc

USE [AdventureWorks2008R2]
GO
/****** Object:  StoredProcedure [dbo].[SP_countbyfirstName]    Script Date: 08/31/2014 08:49:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER proc [dbo].[SP_countbyfirstName] 
@firstname varchar(50)
as

Declare @cntno Int
select @cntno= COUNT(*)from Person.Person where FirstName like  @firstname +'%'

If (@cntno=95) 
begin
select * from Person.Person where FirstName like @firstname +'%'
end

If (@cntno<>95) 
begin
select * from Person.Person where FirstName like @firstname +'%'
end




Substring,Left,right

SELECT LastName,firstname, SUBSTRING(LastName, 4, 4) as Initial

FROM Person.Person

WHERE LastName like 'Barl%'

ORDER BY LastName;

select * from Person.Person

--SUBSTRING ( expression ,start , length )

Select AddressLine1,SpatialLocation,SUBSTRING(cast(SpatialLocation as varchar(50)), 4, 4) as Address

from Person.Address

select PostalCode from Person.Address

SELECT firstName,lastname,RIGHT(FirstName, 4) AS 'First Name'

FROM Person.Person

SELECT firstName,lastname,left(FirstName, 2) AS 'First Name'

FROM Person.Person

SELECT firstName,lastname,SUBSTRING(FirstName,1,2) AS 'First Name'

FROM Person.Person

Saturday, August 30, 2014

IIS Wiki

Internet Information Services (IIS, formerly Internet Information Server) is an extensible web server created byMicrosoft for use with Windows NT family.[2] IIS supports HTTPHTTPSFTPFTPSSMTP and NNTP. It has been an integral part of the Windows NT family since Windows NT 4.0, though it may be absent from some editions (e.g. Windows XP Home edition). IIS is not turned on by default when Windows is installed. The IIS Manager is accessed through the Microsoft Management Console or Administrative Tools in the Control Panel.

http://en.wikipedia.org/wiki/Internet_Information_Services


Most Commonly Used Functions in SQL Server 2005/2008

Friday, August 29, 2014

JavaScript Tutorial

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="javaDefault.aspx.vb" Inherits="javaDefault" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
<h1>My First JavaScript</h1>

<p>Click Date to display current day, date, and time.</p>

<button type="button" onclick="myFunction()">Date</button>

<p id="demo"></p>
<button type="button" onclick="ImageClick()">ReDirect</button>
<asp:TextBox ID="txtPagingGoto"  Width="215px" runat="server"></asp:TextBox>
       
          <div>
        <asp:TextBox ID="txtFirstName" runat="server" OnClick ="ValidateInput()"  ></asp:TextBox>
    </div>          

    </div>
    </form>


    
<script type="text/javascript">
    function myFunction() {
        document.getElementById("demo").innerHTML = Date();
    }

    function ImageClick() {
        window.location.href("http://www.google.com/");
    }
  

    function ValidateInput() {
        var validationMessage = "";
        var isValid = true;
        // keep as many as you want
        var inputControls = ['<%= txtFirstName.ClientID %>', '<%= txtFirstName.ClientID %>'];
        for (var i = 0; i < inputControls.length; i++) {
            if (document.getElementById(inputControls[i]).value = '') {
                // update the message
                isValid = false;
            }
        }
        if (!isValid)
            alert(validationMessage);
        return false;
    }
</script> 




</body>
</html>

Monday, August 18, 2014

Linked Servers SQL Server

Configure a linked server to enable the SQL Server Database Engine to execute commands against OLE DB data sources outside of the instance of SQL Server. Typically linked servers are configured to enable the Database Engine to execute a Transact-SQL statement that includes tables in another instance of SQL Server, or another database product such as Oracle. Many types OLE DB data sources can be configured as linked servers, including Microsoft Access and Excel. Linked servers offer the following advantages:


SQL Server Replication


Replication is a set of technologies for copying and distributing data and database objects from one database to another and then synchronizing between databases to maintain consistency. Using replication, you can distribute data to different locations and to remote

Sunday, August 17, 2014

SQL Server Interview Question

SQL Profiler download

Launching Performance Monitor

Launching Performance Monitor

You can launch Performance Monitor a few different ways.

Start > Control Panel > Administrative Tools > Performance Monitor or you can launch PerfMon.exe.  Once this is running you will get an interface like the following:


http://www.mssqltips.com/sqlservertutorial/283/performance-monitor/