Thursday, January 29, 2015

Insert into Table Execute SP

 

declare @field1 varchar(1000)

declare @field2 varchar(1000)

CREATE TABLE #tempTable(FormulaType Varchar(100),co Varchar(5),      Amount float)

declare cur CURSOR LOCAL for

    --select field1, field2 from sometable where someotherfield is null

       select top 10 CustomList_Name,CustomList_Item  from mfdb.dbo.tblMF_Custom

      

 

open cur

 

fetch next from cur into @field1, @field2

 

while @@FETCH_STATUS = 0 BEGIN

 

    --execute your sproc on each row

 

insert into #tempTable(FormulaType,co,Amount)

   execute SP_testfunc  @field1,@field2

   --print @field1

 

    fetch next from cur into @field1, @field2

END

 

close cur

deallocate cur

 

select * from #tempTable

 

 


Sunday, November 9, 2014

Classic asp database connection

<!DOCTYPE html>
<head>
    <title></title>
</head>
<body>
    <%
        'Dim cnn
'Set cnn = Server.CreateObject("ADODB.Connection")
'cnn.open "PROVIDER=SQLOLEDB;DATA SOURCE=SHIVALISAANVI;UID=ituser;PWD=123456;DATABASE=AdventureWorks2008R2 "
%>
        <%

'Dim conn
'Set conn = Server.CreateObject("ADODB.Connection")

'conn.Open "Provider=SQLOLEDB; Data Source = (SHIVALISAANVI); Initial Catalog = AdventureWorks2008R2; User Id = ituser; Password=123456"

'If conn.errors.count = 0 Then   
'   Response.Write "Connected OK"
'End If


      
        %>
    <% 
'declare the variables 
Dim Connection
Dim Recordset
Dim SQL

'declare the SQL statement that will query the database
SQL = "SELECT TOP 10 *   FROM [AdventureWorks2008R2].[Person].[Person]"

'create an instance of the ADO connection and recordset objects
Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")

'open the connection to the database
Connection.Open  "PROVIDER=SQLOLEDB;DATA SOURCE=SHIVALISAANVI;UID=ituser;PWD=123456;DATABASE=AdventureWorks2008R2 "


'Open the recordset object executing the SQL statement and return records 
Recordset.Open SQL,Connection

'first of all determine whether there are any records 
If Recordset.EOF Then 
Response.Write("No records returned.") 
Else 
'if there are records then loop through the fields 
Do While NOT Recordset.Eof   
Response.write Recordset("FirstName") &"  "
Response.write Recordset("MiddleName")&" "
Response.write Recordset("LastName")&" "
Response.write "<br>"    
Recordset.MoveNext     
Loop
End If

'close the connection and recordset objects to free up resources
Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=nothing
%>

</body>
</html>

Thursday, November 6, 2014

Fwd: Process Oracle Visual Studios Connection


1. Install Oracle Client 32 Bit

2. in VS 2010 -> View -> Server Explorer

3. Right Click on Data Connection ->  Add Connection ->

in server name ->  //OracleServerName:PortNo/InstenceName

//dc01xxxxxxx03.xxxxxx.ccc:80903/hixxjd

user id and password

 

4. Test connection

gridview -> use director-> Create connection string

 

 

and SQL statement

 

SELECT  * FROM DevUSER(Schema Name).[Table Name] WHERE ROWNUM <= 100

 

 

 


Wednesday, October 1, 2014

Javascript enable/disable 32

about:config

  1. In the address bar, type "about:config" (with no quotes), and press Enter.
  2. Click "I'll be careful, I promise"
  3. In the search bar, search for "javascript.enabled" (with no quotes).
  4. Right click the result named "javascript.enabled" and click "Toggle". JavaScript is now disabled.

 https://support.mozilla.org/en-US/questions/967344


Sunday, September 7, 2014

gtalk

Here is a download directly from Google: http://dl.google.com/googletalk/googletalk-setup.exe

--
Thanks
Shweta Sharma
http://www.svdeals.com

Tuesday, September 2, 2014

Find Column name in SQL serverTable

SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name = 'billclasscode'
ORDER BY schema_name, table_name;

Monday, September 1, 2014

Update join 2 table SQL _SERVER

select lipqoh,TRQT,liitm,itm,lilocn,locn
--UPDATE proddta.f41021 SET lipqoh =trqt
from proddta.f41021 
INNER JOIN zdev.dbo.temp_pqoh  on liITM=itm and rtrim(ltrim(limcu))=rtrim(ltrim(mcu)) and lilocn=locn
where rtrim(ltrim(limcu))=rtrim(ltrim(mcu)) and liITM=itm  and lilocn=locn and
rtrim(ltrim(limcu))=rtrim(ltrim(mcu)) and lipqoh<>trqt

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