September 1, 2006 at 10:21 pm
Hey All,
I've stored procedure for exporting and populating data from databases located on outlets/branch offices to database located on head office.
for example :
i've 5 outlets databases just name it outlet1, outlet2,...,outlet5 and 1 database as data warehouse,name it central.All databases above are located in one machine on head office.
Data collected from each outlets and restored into db server machine on head office with corresponding name.
so, i'm writing a stored procedure with several parameters, one of them is @dbname varchar(20) that represents outlet database name like outlet1, outlet2, and so on.
how can i use this parameter in sql statement form like this :
SELECT
*
INTO
central.dbo.Table1
FROM
some_function_to_convert_varchar_into_dbobject(@dbname).dbo.Table1
--OR Using with cursor
DECLARE MyCur INSENSITIVE CURSOR FOR
SELECT
*
FROM
some_function_to_convert_varchar_into_dbobject(@dbname).dbo.Table1
i've been tried to looking for the function that acts like some_function_to_convert_varchar_into_dbobject function on sql server help.There is only 2 functions i've been founded that is DB_ID and DB_NAME that acts like that,but did'nt return value as db object except varchar and int.
i have planning to place this stored procedure on central database.
thanks for any help.
my english is not good enough, so please forgive me if any faults.
September 4, 2006 at 8:00 am
This was removed by the editor as SPAM
September 5, 2006 at 4:17 am
There is now way to do this as far as I know.
However, in a round about way there is.
If you use 'sp_helpdb', you will get back all the database names on the server. You could try outputting this into a temprary table, then querying the table to find the actual database name using 'like %dbname'. IE if you know the db name always starts with the same letters, it will be easy.
Best I can come up with.
September 5, 2006 at 4:29 am
Thx For Reply,
This problems have been solved with the assist of all you guys, especially Ramesh.
Thx Very Much.
M.F.R
September 6, 2006 at 7:41 pm
Funny, I don't see a post here by Ramesh... So, what did you guys come up with?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply