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

Sharepoint 2007 service pack 2 (sp2) locks Site Collections during backup

Wednesday, 24 June 2009 16:06 by myro

After upgrading a SharePoint farm to Service Pack 2 you could find out that sometimes your Site Collection is locked and no administrative tasks can be done. If you have scheduled backups using the stsadm, you will find out that this lock is active only when your back up jobs are runnig.
This happens because the stsadm command backup (stsadm -o backup) now locks by default your site collection. As you can see this option is implemented by default:

stsadm -o backup
 -url <URL name>
 -filename <file name>
 [-nositelock]
 [-overwrite]

http://technet.microsoft.com/en-us/library/cc263441.aspx

for more infos about the nositelock option, visit http://technet.microsoft.com/en-us/library/cc262811.aspx

Hope it helps.

Be the first to rate this post

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

Insert into one table from another table SQL

Monday, 22 June 2009 18:00 by myro

Just a quick note to myself. I can never seem to find an example of this when I need it.
This insert statement copies records from TABLE_2 to TABLE_1 with some custom values

INSERT INTO TABLE_1 (Prd_ID, Sta_ID, StS_ID, TiP_ID, Prd_Titolo, Prd_Descrizione, Prd_ID_Catalogo, Prd_Notifica)
SELECT (SELECT max(Prd_ID) from INTO TABLE_1)+1, 1, 1, 17,  [INTO TABLE_2].Descrizione,  [INTO TABLE_2].Descrizione,  [INTO TABLE_2].Codice, 'N'
FROM [INTO TABLE_2]
WHERE  ([INTO TABLE_2].ID = 3)

hope this post can refresh your mind too...

Be the first to rate this post

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