Showing posts with label MS SQL. Show all posts
Showing posts with label MS SQL. Show all posts

Saturday, 21 November 2015

Delete all stored procedure of database using sql query

Introduction:

Here i will show you sql query for how to delete all stored procedure of database with single query

Explanation:

Here i have used cursor to delete all stored procedure of table.You just copy and paste below query to your sql query editor.

USE <database name>
 DECLARE @UserStoredProcedure    VARCHAR(100)
   DECLARE @Command                    VARCHAR(100)
 DECLARE UserStoredProcedureCursor CURSOR SCROLL STATIC READ_ONLY FOR
 SELECT
       SPECIFIC_NAME
   FROM
     INFORMATION_SCHEMA.ROUTINES
   OPEN UserStoredProcedureCursor
   FETCH NEXT FROM UserStoredProcedureCursor
   INTO @UserStoredProcedure
 WHILE (@@FETCH_STATUS = 0) BEGIN
          SET @Command = 'DROP PROCEDURE ' + @UserStoredProcedure

            -- display; visual check
          SELECT @Command
 

Thursday, 19 November 2015

Get table's row number in ms sqlserver


Introduction:

             I will explain here how to get  row number of table using sql query.

Explanation:

             If you want to get row number for particular row of table or row numbers of table you can use ROW_NUMBER () key word here i used to show query for getting row number of brcon_tbl where brcate_ID='3'.

SELECT ROW_NUMBER()OVER (ORDER BY brcon_ID) AS Row,brcon_ID  FROM brcon_tbl  WHERE brcate_ID ='3'