Reply to Dynamic database selection?

Your name:

Reply:


Posted by Ed Murphy on 06/15/07 01:32

I'm working on a script to convert data from one software package
to another. Greatly simplified, it looks something like

create procedure import_widget as
begin

insert into our_widget (foo, bar)
select baz, quux from their_db.dbo.their_widget

end
go

The problem is that the name of the source database varies from
one system to another, so I want to pass the database name as a
parameter. I think I could do the following, but is there a
better way to go about it?

create procedure import_widget (@db_name sysname) as
begin

exec 'create view their_widget as select * from '
+ @db_name + '.dbo.their_widget'

insert into our_widget (foo, bar)
select baz, quux from their_widget

drop view their_widget

end
go

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация