Re: System sproc to channel to database(s)
From: Eric Sabine (mopar41_at____ho_y_tmail.ScPoAmM)
Date: 05/07/04
- Next message: Rohan Hattangdi: "Re: Bad decision? Optional parameters - system-wide change."
- Previous message: Anith Sen: "Re: _hypmv_0 - unknown dependency"
- In reply to: JT: "System sproc to channel to database(s)"
- Next in thread: JT: "Re: System sproc to channel to database(s)"
- Reply: JT: "Re: System sproc to channel to database(s)"
- Reply: JT: "Re: System sproc to channel to database(s)"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 7 May 2004 14:12:14 -0400
See if something like this will help you. Keep in mind it requires execute
permissions in master.
hth,
Eric
use northwind
create table tester123 (col1 int identity not null, col2 char(1) not null)
use pubs
create table tester123 (col1 int identity not null, col2 char(1) not null)
use master
go
create proc sp_insertSomething (@value char(1))
as
begin
insert tester123 values(@value)
return @@identity
end
exec dbo.sp_MS_marksystemobject 'dbo.sp_insertSomething'
use northwind
exec sp_insertSomething 'a'
exec sp_insertSomething 'b'
exec sp_insertSomething 'c'
use pubs
exec sp_insertSomething 'd'
exec sp_insertSomething 'e'
exec sp_insertSomething 'f'
use master
select * from northwind.dbo.tester123
select * from pubs.dbo.tester123
drop proc sp_insertSomething
use pubs
drop table tester123
use northwind
drop table tester123
"JT" <JTnospam@verizon.net> wrote in message
news:A465C1D6-DC22-43AD-8832-713EED31647C@microsoft.com...
> HI,
> I am wondering if it is possible to set-up a stored procedure in Master
that I can then use as a "channel" to insert values into identically named
tables in different databases (ie, sproc A resides in DB1, DB2, DB3....
DB1, 2, and 3 all have identical structure, but are repositories for data
from different clients).
> i was trying to use sp_databases to get the database name, assign it to a
declared variable, and then concatenate this into a fully qualified table
name. For example:
>
> DECLARE @dbName sysname
> INSERT [@dbName].dbo.myTable(......
>
> This led to the error unrecognized object name. I saw examples of ways to
concatenate this type of thing in an execute script, like N' + @dbName +
'].[' ......, but I dont think this will work for me. I say that because my
sproc has to deliver table metadata as the basis for a BizTalk Server SQL
Adapter. Therefore, it has to end with
>
> FOR XML RAW, XMLDATA
>
> What could also solve my dilemma here would be if the sql adapter's conn
string could be dynamically assigned based on the incoming message, but I
don't think this is the case.
>
> Anyway, can anyone tell me if this use of a system sproc as a
'channelizer' to direct inserts to a particular database is possible,
keeping in mind the XML requirement. Thanks
>
> John
- Next message: Rohan Hattangdi: "Re: Bad decision? Optional parameters - system-wide change."
- Previous message: Anith Sen: "Re: _hypmv_0 - unknown dependency"
- In reply to: JT: "System sproc to channel to database(s)"
- Next in thread: JT: "Re: System sproc to channel to database(s)"
- Reply: JT: "Re: System sproc to channel to database(s)"
- Reply: JT: "Re: System sproc to channel to database(s)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|