Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How can I use Database name inside Stored Procedur

Author  Topic 

azamsharp
Posting Yak Master

201 Posts

Posted - 2005-12-31 : 23:47:50
Hi,

How can I pass database name to the stored procedures? I want to use something like this:

USE Northwind

But I cannot use USE statement inside the stored procedure. How can I achieve this.

Thanks,
AzamSharp

Mohammad Azam
www.azamsharp.net

sachinsamuel
Constraint Violating Yak Guru

383 Posts

Posted - 2006-01-01 : 02:40:13
why do you want to use 'Use' ???

You can directly write in your stored procedure as below

Create proc test
as
select * from [northwind]..customers
go


Regards
sachin

Don't sit back because of failure. It will come back to check if you still available. -- Binu
Go to Top of Page

azamsharp
Posting Yak Master

201 Posts

Posted - 2006-01-01 : 02:42:13
Yeah thanks!

Mohammad Azam
www.azamsharp.net
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-02 : 01:54:27
Usage of Use is not allowed inside stored Procedure and you need to use DbName..tableName as suggested or Dbname.owner.tableName

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -