Click here to Skip to main content
15,886,362 members
Home / Discussions / Database
   

Database

 
AnswerRe: Problem with ISNULL Pin
Michael Potter15-Oct-07 5:44
Michael Potter15-Oct-07 5:44 
Questionexception Pin
Trustapple15-Oct-07 0:32
Trustapple15-Oct-07 0:32 
AnswerRe: exception Pin
Andy_L_J15-Oct-07 2:54
Andy_L_J15-Oct-07 2:54 
AnswerRe: exception Pin
Mike Dimmick15-Oct-07 4:02
Mike Dimmick15-Oct-07 4:02 
QuestionJOINS Pin
karoitay14-Oct-07 23:53
karoitay14-Oct-07 23:53 
AnswerRe: JOINS Pin
John-ph14-Oct-07 23:56
John-ph14-Oct-07 23:56 
Generalthanks Pin
karoitay15-Oct-07 0:26
karoitay15-Oct-07 0:26 
QuestionHow do I pass DB name as parameter to stored procedure? Pin
Steven J Jowett14-Oct-07 22:22
Steven J Jowett14-Oct-07 22:22 
I have an MS SQL Server 2005 database that uses data from another MS SQL Server database created by a third-party software company. Both are in the as instance.

I wish to create a stored procedure in my database to retrieve data from the third-party database.

The following code works fine :-

SELECT TOP (100) PERCENT NLNominalAccountID AS NominalAnalysisId, AccountNumber, AccountCostCentre AS CostCentre, AccountDepartment AS Department, AccountName<br />
FROM  MMSv3_DemoData.dbo.NLNominalAccount<br />
ORDER BY AccountNumber, CostCentre, Department


The MMSv3_DemoData is the third-party database.

My problem is that I wish to my the database name an input parameter as have tried the following code :-

set ANSI_NULLS ON<br />
set QUOTED_IDENTIFIER ON<br />
go<br />
<br />
ALTER PROCEDURE [dbo].[spGetNominalAccounts]<br />
@Database AS VarChar(50)<br />
AS<br />
BEGIN<br />
SET NOCOUNT ON;<br />
SELECT     TOP (100) PERCENT NLNominalAccountID AS NominalAnalysisId, AccountNumber, AccountCostCentre AS CostCentre, AccountDepartment AS Department, AccountName<br />
FROM         [@Database].dbo.NLNominalAccount<br />
ORDER BY AccountNumber, CostCentre, Department;<br />
END<br />


What I get when executing the stored procedure is :-

Invalid object name '@Database.dbo.NLNominalAccount'.

Any help apprceiated.

Thanks


-- modified at 4:51 Monday 15th October, 2007

Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'

AnswerRe: How do I pass DB name as parameter to stored procedure? Pin
Marek Grzenkowicz14-Oct-07 23:43
Marek Grzenkowicz14-Oct-07 23:43 
GeneralRe: How do I pass DB name as parameter to stored procedure? Pin
Steven J Jowett14-Oct-07 23:54
Steven J Jowett14-Oct-07 23:54 
QuestionUnable to complete login process due to delay in opening server connection Pin
Anilkumar K V14-Oct-07 20:39
Anilkumar K V14-Oct-07 20:39 
QuestionDatabase is suspect Pin
Phan Van Thao14-Oct-07 16:19
Phan Van Thao14-Oct-07 16:19 
AnswerRe: Database is suspect Pin
Pete O'Hanlon15-Oct-07 2:01
mvePete O'Hanlon15-Oct-07 2:01 
GeneralRe: Database is suspect Pin
Phan Van Thao15-Oct-07 15:03
Phan Van Thao15-Oct-07 15:03 
QuestionWindows authentication - not prompted? [modified] Pin
dandy7214-Oct-07 11:36
dandy7214-Oct-07 11:36 
AnswerRe: Windows authentication - not prompted? Pin
Mike Dimmick15-Oct-07 3:52
Mike Dimmick15-Oct-07 3:52 
GeneralRe: Windows authentication - not prompted? Pin
dandy7215-Oct-07 10:15
dandy7215-Oct-07 10:15 
QuestionSet Null in Ms Access DB again! Pin
Whoami Whoami14-Oct-07 8:35
Whoami Whoami14-Oct-07 8:35 
AnswerRe: Set Null in Ms Access DB again! [modified] Pin
pmarfleet14-Oct-07 10:02
pmarfleet14-Oct-07 10:02 
QuestionSystem.Data.OleDb.OleDbException Pin
s4_sabahatf14-Oct-07 8:31
s4_sabahatf14-Oct-07 8:31 
AnswerRe: System.Data.OleDb.OleDbException Pin
Mike Dimmick14-Oct-07 11:06
Mike Dimmick14-Oct-07 11:06 
QuestionSQL Server Batch jobs Pin
naren37814-Oct-07 7:32
naren37814-Oct-07 7:32 
AnswerRe: SQL Server Batch jobs Pin
Marek Grzenkowicz14-Oct-07 23:49
Marek Grzenkowicz14-Oct-07 23:49 
QuestionDeploy .Net Application With Sql Server 2005 Pin
DotNetWWW14-Oct-07 6:46
DotNetWWW14-Oct-07 6:46 
AnswerRe: Deploy .Net Application With Sql Server 2005 Pin
Mike Dimmick14-Oct-07 11:26
Mike Dimmick14-Oct-07 11:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.