[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.sqlserver.programming

update same SP in all database (in one sql server

Agnes Cheng

3/16/2007 7:20:00 AM

My sql server ont over 50 Database, and they got one standard and samme
Store Procedure
Now, I need to update this SP.
for my old method. I place the SP content into SQL analyzer and choose each
Database and then press "run"
For 50 databases , I need to choose 50 times and press 50 times.

Any simple method ?
such as I write a program and pass the database name to that program.
program A -> call program B
program A got selected database list --> program B "contains updated SP"
Thanks


3 Answers

masri999

3/16/2007 8:51:00 AM

0

On Mar 16, 12:20 pm, "Agnes" <a...@dynamictech.com.hk> wrote:
> My sql server ont over 50 Database, and they got one standard and samme
> Store Procedure
> Now, I need to update this SP.
> for my old method. I place the SP content into SQL analyzer and choose each
> Database and then press "run"
> For 50 databases , I need to choose 50 times and press 50 times.
>
> Any simple method ?
> such as I write a program and pass the database name to that program.
> program A -> call program B
> program A got selected database list --> program B "contains updated SP"
> Thanks

I assume you are using SQL 2000 . In that case write a script an run
through osql

Rahul

3/16/2007 10:35:00 AM

0

On Mar 16, 1:51 pm, "M A Srinivas" <masri...@gmail.com> wrote:
> On Mar 16, 12:20 pm, "Agnes" <a...@dynamictech.com.hk> wrote:
>
> > My sql server ont over 50 Database, and they got one standard and samme
> > Store Procedure
> > Now, I need to update this SP.
> > for my old method. I place the SP content into SQL analyzer and choose each
> > Database and then press "run"
> > For 50 databases , I need to choose 50 times and press 50 times.
>
> > Any simple method ?
> > such as I write a program and pass the database name to that program.
> > program A -> call program B
> > program A got selected database list --> program B "contains updated SP"
> > Thanks
>
> I assume you are using SQL 2000 . In that case write a script an run
> through osql




Exec sp_ExecDLLFromAllDatabases '\\test\C:\Test.txt', 'Adb, Bdb, Cdb'

Create Procedure sp_ExecDLLFromAllDatabases
(
@pFilePath VarChar(500),
@pDatabases VarChar(8000)
)
AS
Begin
Declare @lDatabase VarChar(100),
@lpos Int,
@Cmd VarChar(8000)

Set @lDatabase = ''
Set @pDatabases = @pDatabases + ','
Set @lpos = PatIndex('%,%', @pDatabases)
While (@lpos > 0)
Begin
Set @lDatabase = lTrim(rTrim(SubString(@pDatabases, 1, @lpos - 1)))
Set @pDatabases = SubString(@pDatabases, @lpos + 1,
Len(@pDatabases))
Set @lpos = PatIndex('%,%', @pDatabases)
Set @Cmd = 'Use ' + @lDatabase + '; '
Set @Cmd = @Cmd + 'master..xp_cmdshell type ' + @pFilePath
End
End



--Rahul

Hari

3/16/2007 1:08:00 PM

0

Hello,

Save the stored procedure in a .SQL file. Then call the .SQL file using OSQL
and put it into a BAT file. In the same BAT file
add one entry for each database. Save the file and just double click. THis
will craete / alter the procedure in all databases

In OSQL you may need to use -i and -d options

Thank
Hari

"Agnes" <agnes@dynamictech.com.hk> wrote in message
news:OBGfKu5ZHHA.2076@TK2MSFTNGP04.phx.gbl...
> My sql server ont over 50 Database, and they got one standard and samme
> Store Procedure
> Now, I need to update this SP.
> for my old method. I place the SP content into SQL analyzer and choose
> each Database and then press "run"
> For 50 databases , I need to choose 50 times and press 50 times.
>
> Any simple method ?
> such as I write a program and pass the database name to that program.
> program A -> call program B
> program A got selected database list --> program B "contains updated SP"
> Thanks
>