TSQL

     

  • TSQL denotes about Transact SQL
  •  

     

    Delcare a variable

     

  • DECLARE is a key word, used to declare a varibale
  • "DECLARE @VARIABLENAME DATATYPE
  • Ex: Declare @abc int
  •  

    Assign value to variable

     

  • SET is a key word which is used to assign\store value in variable
  • SET @abc = 15
  •  

    CURSOR

     

  • Cursor is useful to Iterate the rows
  •  

     

    Declare Cursor:

  • Declare Cursorname Cursor
  •  

  • DECLARE CURSOR FOR QUERY is the statement used for declaration
  •  

    OPEN Cursor :

  • OPEN CursorName
  •  

    Retrieve records from CURSOR:

  • We use FETCH Statement
  •  

     

  • FETCH FIRST: Returns First row of record set
  • FETCH NEXT: Returns Next row
  • FETCH PRIOR: Returns Previous record
  • FETCH ABSOLUTE: Returns absolute row number
  • FETCH RELATIVE: Returns the row based on its relative position
  • FETCH LAST: Returns Last record
  •  

    CLOSE CursorName :

  • CLOSE CursorName
  •  

    DEALLOCATE the Cursor:

     

     

    Provide the Grades to the Marks

     

  • Provide the Grades based on marks using IF condition
  •