Hi
I am trying to write stored procedure which use multiple database on same server but need to swich between databases..
create procedure dbo.ListImport(
@ps_ListDBName varchar(50),
@ps_OrderDBName varchar(50))
begin
Declare @iCount numeric
--use [@ps_ListDBName] how to do this?
select @iCount=count(*) from @ps_ListDBName..users
print @iCount
--use [@ps_OrderDBName] how to do this?
select @iCount=count(*) from @ps_OrderDBName..users
print @iCount
Select * from user--Output to text file..how to do this?
end
Any idea?
Thank you
I am trying to write stored procedure which use multiple database on same server but need to swich between databases..
create procedure dbo.ListImport(
@ps_ListDBName varchar(50),
@ps_OrderDBName varchar(50))
begin
Declare @iCount numeric
--use [@ps_ListDBName] how to do this?
select @iCount=count(*) from @ps_ListDBName..users
print @iCount
--use [@ps_OrderDBName] how to do this?
select @iCount=count(*) from @ps_OrderDBName..users
print @iCount
Select * from user--Output to text file..how to do this?
end
Any idea?
Thank you