Execute a stored procedure at SQL Server Management Studio with output parameter

Monday, 29 June 2009 17:27 by myro

Here's a reminder for myself when I need to launch a stored procedure with an output parameter directly from SQL Server Management. Who knows... maybe can helps you too.

declare @P1 int

set @P1=NULL

declare @P2 char(1)

set @P2=NULL

exec STORED_PROCEDURE 0, 'foo', 144133917, '0', @P1 output, @P2 output select @P1, @P2

go

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   Sql
Actions:   Bookmark and Share | Permalink | Comments (0) | Comment RSSRSS comment feed

SQL Find all procedures that contains a specific text

Monday, 29 June 2009 09:59 by myro

Let's says you need to find out all the stored procedures that reference a column or that just contains a text. You can use:

SELECT ROUTINE_NAME, ROUTINE_DEFINITION 
    FROM INFORMATION_SCHEMA.ROUTINES 
    WHERE ROUTINE_DEFINITION LIKE '%foobar%' 
    AND ROUTINE_TYPE='PROCEDURE'

Things get simplier if you are in SQL Server 2005; start a new query and paste this:

SELECT Name 
    FROM sys.procedures 
    WHERE OBJECT_DEFINITION(object_id) LIKE '%foobar%' 

Reference: http://databases.aspfaq.com/database/how-do-i-find-a-stored-procedure-containing-text.html

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   Sql
Actions:   Bookmark and Share | Permalink | Comments (1) | Comment RSSRSS comment feed

SQL Server - Find all Tables in Database that contains a specific column

Thursday, 25 June 2009 10:59 by myro

If you need to query your sql server's database to find out where a specific column is present into a table's schema, you can lauch this query against your database.

USE YOUR_DATA_BASE_NAME
GO
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 LIKE '%YOUR_Column_NAME%'
ORDER BY schema_name, table_name;

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   Sql
Actions:   Bookmark and Share | Permalink | Comments (2) | Comment RSSRSS comment feed