Back To Normal

Subscribe To Our E-Mail Newsletter

Tuesday, May 18, 2010

Change the column name of table in oracle?

alter table tablename rename column column1 to column2;
Read More


Send mail in Outlook through the vbs?

Dim objOutlook
Dim objOutlookMsg
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
objOutlookMsg.To = "test@domain.com"
objOutlookMsg.CC = ""
objOutlookMsg.BCC = ""
objOutlookMsg.Subject = " Build Notification Started"
objOutlookMsg.Body = "Dear ASP Manager, Build Notification Started"
 objOutlookMsg.Attachments.Add "D:\test.txt"
objOutlookMsg.Send
Read More


Thursday, May 6, 2010

Read the Log Files from server using Vbs?

Dim FileSystemObj
Dim NotepadObj,strLine,objFile
Dim ResultFilePath,sSearchMsg

REM Arguments Form Command Propmt

If WScript.Arguments.Count = 1 Then
 sSearchMsg = WScript.Arguments.Item(0)
Else
 sSearchMsg ="FAIL"
End If

REM For log File and Result File Creattion.
ResultFilePath ="D:\Automation Results\LatestResults.txt"
Set FileSystemObj = CreateObject("Scripting.FileSystemObject")
Set ResultdObj =FileSystemObj.CreateTextFile(ResultFilePath)
ResultdObj.Close
ReadDataFromTextFile("\\BD07860A\DDrive\rpm_scripts\TestResults\Status.log")
ReadDataFromTextFile("\\blrd1497\D\rpm_scripts\TestResults\Status.log")
ReadDataFromTextFile("\\vmlancer\D\rpm_scripts\TestResults\Status.log")
REM ResultdObj.Close

Function ReadDataFromTextFile(InputFile)

 Set objFSO = CreateObject("Scripting.FileSystemObject")
 Set objDictionary = CreateObject("Scripting.Dictionary")
Set objTextFile = FileSystemObj.OpenTextFile(ResultFilePath,8)

 Const ForReading = 1

 Set objFile = objFSO.OpenTextFile (InputFile, ForReading)
 i = 0
 Do Until objFile.AtEndOfStream
  strNextLine = objFile.Readline
  If strNextLine <> "" Then
    IF InStr(strNextLine, sSearchMsg)Then
     objDictionary.Add i, strNextLine
    
    End If
  End If
  i = i + 1
 Loop
 objFile.Close

objTextFile.WriteLine("*****START LOG Machine :" &  InputFile  &"******************************")
objTextFile.WriteLine(" ")
objTextFile.WriteLine(" ")
 For Each strLine in objDictionary.Items
  objTextFile.WriteLine(strLine)
 Next
objTextFile.WriteLine("*****END LOG Machine :" &  InputFile  &"******************************")
objTextFile.WriteLine(" ")
objTextFile.WriteLine(" ")
 objTextFile.Close
End Function
Read More


Find out Difference between two Excels using Vbs?

 
 
  Dim sExcelFile1
  Dim sTextFile1,FSO
  Dim TextStream,TextStream1
  Dim S,fso1,s1,ResFile,sDiff
  Dim File,File1
  Set fso1 = CreateObject("Scripting.FileSystemObject")
  Set ResFile = fso1.CreateTextFile("D:\diffFile.txt", True)
 
  sExcelFile1 ="C:\Documents and Settings\vgurusam\Desktop\reliance.xls"
  sExcelFile2 ="C:\Documents and Settings\vgurusam\Desktop\Copy of reliance.xls"
  sTextFile1 ="D:\testfile.txt"
  sTextFile2 ="D:\testfile1.txt"
  Call ReadExcel (sExcelFile1,sTextFile1)
  Call ReadExcel (sExcelFile2,sTextFile2)
 
  Set FSO = CreateObject("Scripting.FileSystemObject")
  Set File = FSO.GetFile(sTextFile1)
  Set File1 = FSO.GetFile(sTextFile2)
  Set TextStream = File.OpenAsTextStream(1)
  Set TextStream1 = File1.OpenAsTextStream(1)
  
   Do    While Not TextStream.AtEndOfStream
      S =  TextStream.ReadLine & NewLine
      s1=  TextStream1.ReadLine & NewLine
      If (S <> s1) Then
        sDiff="Different Cell:: " & " String1 ::" & S & " String2 ::" & S1
'       WScript.Echo (S1)
       ResFile.WriteLine(sDiff)
      End If
      s1 =""
      S=""
      sDiff=""
   Loop
   TextStream.Close
TextStream1.Close
ResFile.close
 

  Function ReadExcel(sExcelFile,sTextFilePath)

   Dim fso, MyFile
   Set fso = CreateObject("Scripting.FileSystemObject")
  ' Set MyFile = fso.CreateTextFile("D:\testfile.txt", True)
    Set MyFile = fso.CreateTextFile(sTextFilePath, True)
    Dim sExcelPath 'As Variant  'Excel file
    '********** Excel object declaration **********'
     ' Excel Application object
    Dim objExcel 'As Excel.Application
    Dim objXLWorkbooks 'As Excel.Workbooks
    Dim objXLWorkbook 'As Excel.Workbook

    Dim WorkSheetCount 'As Variant  'Work sheets count in a excel
    Dim CurrentWorkSheet 'As Excel.Worksheet    ' Current worksheet
    Dim objCells 'As Excel.Range
    Dim objCurrentCell 'As Variant
    Dim objFont 'As Variant

    ' Result contents
    Dim sCellText 'As Variant
    Dim sFontName 'As Variant
    Dim sFontStyle 'As Variant
    Dim iFontSize 'As Variant
    Dim iCellTextColorIndex 'As Variant
    Dim iCellInteriorColorIndex 'As Variant
    Dim sResult 'As Variant
    Dim sChartFile 'As String


    ' Row and Col integer variables
    Dim iUsedRowsCount 'As Integer
    Dim iUsedColsCount 'As Integer
    Dim iTop, iLeft 'As Integer
    Dim iRow 'As Integer     'Row item
    Dim iCol 'As Integer     'Col item
    Dim iCurRow 'As Integer
    Dim iCurCol 'As Integer


    If (sExcelFile = "") Then
            sExcelPath = "D:\excel.xls"
    Else
            sExcelPath = sExcelFile
    End If

    If (iSheetIndex = "") Then
        iSheetIndex = 1
    End If


'    Call FileDeleteAndCreate (gsLogFile)

    'XL file check
'    If (FileExists(sExcelPath) <> 0) Then
'        Call LogWrite (gsLogFile, "The Excel file " & Chr(34) & sExcelPath & Chr(34) & " does not exit!")
'        Exit sub
'    End If

    Set objExcel = CreateObject("Excel.Application")
    objExcel.Workbooks.Open sExcelPath, False, True

    On Error Resume Next


    WorkSheetCount = objExcel.Worksheets.Count

    Set objXLWorkbook = objExcel.ActiveWorkbook


    Set CurrentWorkSheet = objExcel.ActiveWorkbook.Worksheets(iSheetIndex) 'iSheetIndex worksheet

    iUsedRowsCount = CurrentWorkSheet.UsedRange.Rows.Count
    iUsedColsCount = CurrentWorkSheet.UsedRange.Columns.Count
    iTop = CurrentWorkSheet.UsedRange.Row
    iLeft = CurrentWorkSheet.UsedRange.Column

    CurrentWorkSheet.UsedRange.Columns.AutoFit()
    ' Cells object
    CurrentWorkSheet.Cells.Activate


    For iRow = iTop To iUsedRowsCount   '(iUsedRowsCount - 1)
            'Read All rows
            For iCol = iLeft To iUsedColsCount  '(iUsedColsCount - 1)

                    sResult = ""
                    Set objCurrentCell = CurrentWorkSheet.Cells(iRow, iCol)
                    sCellText = objCurrentCell.Text


                    If ((sCellText = Empty)) Then


                            sResult = "Reading Cell {" & CStr(iRow) & ", " & CStr(iCol) & "}^" &"  "& "^" & "  " & "^" & "  " & "^" & "  " & "^" & "  " & "^" & "  "

                            Call LogWrite (gsLogFile, sResult)

                    Else
                            Set objFont = objCurrentCell.Font
                            sFontName = objFont.Name
                            sFontStyle = objFont.FontStyle
                            iFontSize = objFont.Size
                            iCellTextColorIndex = objFont.Color
                            iCellInteriorColorIndex = objCurrentCell.Interior.ColorIndex



                            If (sFontName = Empty) Then
                                    sFontName = "empty"
                            End If
                            If (sFontStyle = Empty) Then
                                    sFontStyle = "empty"
                            End If
                            If (iFontSize = Empty) Then
                                    iFontSize = "-99999999"
                            End If
                            If (iCellTextColorIndex = Empty) Then
                                    iCellTextColorIndex = "99999999"
                            End If
                            If (iCellInteriorColorIndex = Empty) Then
                                    iCellInteriorColorIndex = "99999999"
                            End If

                            sResult = "Reading Cell {" & CStr(iRow) & ", " & CStr(iCol) & "}^" & sCellText & "^" & CStr(iCellInteriorColorIndex) & "^" & sFontName & "^" & CStr(sFontStyle) & "^" & CStr(iFontSize) & "^" & CStr(iCellTextColorIndex)

'                            Call LogWrite (gsLogFile, sResult)
                            MyFile.WriteLine(sResult)

                    End If

                    Set objCurrentCell = Nothing


            Next

    Next
    MyFile.Close
   
    objExcel.ActiveWorkbook.Saved = True
    Set CurrentWorkSheet = Nothing
    objExcel.Quit
    Set objExcel = Nothing
End Function   
Read More


Monday, May 3, 2010

Stored Functions in SQL Server?

A function always return a value,and it is called inside the sql statements like normal functions.

Examples:

CREATE FUNCTION CALC_AVERAGE (n1 INT, n2 INT)
  RETURNS INT
   DETERMINISTIC
    BEGIN
     DECLARE avg INT;
     SET avg = (n1+n2*2+n4*4)/8;
     RETURN avg;
    END|
Read More


What is Stored Procedure in SQL Server?

Stored Procedures:

Stored procedures are extremely similar to the constructs seen in other programming languages.
They accept data in the form of input parameters that are specified at execution time.

Benifits of Stored Procedures:
1. PreComplied execution
2. Efficient reuse
3. Enhanced security controls

Example:
 CREATE PROCEDURE sp_GetQuantity
 @Name varchar(10)
 AS
 SELECT Product, Quantity
 FROM Product_Table
 WHERE Product = @Name

For executing the above Procedure:
  EXECUTE  sp_GetQuantity 'A7'
Read More


What is Index in the databases?

Index is a set pointers reference to the specific row in the table.It will make Sql search as much more fast.
 
  Example:
  CREATE INDEX IndexName
  ON TableName (ColumnName1,ColumnName2).

For More information:
http://www.databasejournal.com/features/mysql/article.php/1382791/Optimizing-MySQL-Queries-and-Indexes.htm
Read More


560 Free Online Courses

Top 200 universities launched 500 free online courses.  Please find the list here .