Click here to Skip to main content
15,887,349 members
Home / Discussions / Database
   

Database

 
GeneralRe: Installing SQL 2008 VHDs Pin
Mike Dimmick25-Oct-07 5:16
Mike Dimmick25-Oct-07 5:16 
QuestionRestoring backups between SQL Server 2005 Editions Pin
Mridang Agarwalla24-Oct-07 1:50
Mridang Agarwalla24-Oct-07 1:50 
AnswerRe: Restoring backups between SQL Server 2005 Editions Pin
Marek Grzenkowicz24-Oct-07 3:28
Marek Grzenkowicz24-Oct-07 3:28 
QuestionSQL Tables Pin
Illegal Operation24-Oct-07 1:26
Illegal Operation24-Oct-07 1:26 
AnswerRe: SQL Tables Pin
kubben24-Oct-07 1:55
kubben24-Oct-07 1:55 
QuestionConnection Timeout Pin
Anilkumar K V23-Oct-07 22:33
Anilkumar K V23-Oct-07 22:33 
AnswerRe: Connection Timeout Pin
Paul Conrad28-Oct-07 15:08
professionalPaul Conrad28-Oct-07 15:08 
QuestionDynamic table in sql Procedure? Pin
squattyarun23-Oct-07 19:36
squattyarun23-Oct-07 19:36 
HI all,
I am creating a Procedure in which i need to take table name from user as input I m trying to achieve this but getting some errors please help me out.
here is the code....
<br />
set ANSI_NULLS ON<br />
set QUOTED_IDENTIFIER ON<br />
go<br />
<br />
<br />
<br />
<br />
<br />
<br />
ALTER    procedure [dbo].[apo_GetQuestionsByInqTransId]<br />
--Passing inventory id as input variable <br />
--Generate all the questions of it<br />
@InqTransId int,<br />
@appId int,<br />
@option nvarchar(20),<br />
@schema nvarchar(30)<br />
<br />
As<br />
Begin<br />
<br />
	if @option='All'<br />
		begin<br />
				select qm.QID,qm.[name],QM.ParentQID,itql.SequenceNo from QuestionMaster qm,InquiryTransaction it,<br />
				InquiryQuestionLinkage itql   <br />
				where itql.qid=qm.qid and it.InquiryTransId=itql.InquiryTransId<br />
				and it.InquiryTransId=@InqTransId order by QM.ParentQID<br />
		end<br />
	else<br />
		begin<br />
				declare @AnswerDetailTable as nvarchar(40)<br />
				set @AnswerDetailTable =@schema+'.AnswerDetalTable'<br />
				select qm.QID,qm.[name],QM.ParentQID,itql.SequenceNo<br />
				from QuestionMaster qm,InquiryTransaction it,InquiryQuestionLinkage itql   <br />
				where itql.qid=qm.qid and it.InquiryTransId=itql.InquiryTransId<br />
				and it.InquiryTransId=@InqTransId and qm.QID not in(select QID<br />
				from @AnswerDetailTable<br />
				where appId=@appId)   <br />
				order by QM.ParentQID<br />
		end<br />
<br />
End  <br />


In the above code I need ur help in the else statement where I am using @AnswerDetailTable in from clause.
I m geetin error "Msg 102, Level 15, State 1, Procedure apo_GetQuestionsByInqTransId, Line 33
Incorrect syntax near '@AnswerDetailTable'."
wating for suggestions....Smile | :)

Arun Singh
Noida.

AnswerRe: Dynamic table in sql Procedure? Pin
pmarfleet23-Oct-07 21:29
pmarfleet23-Oct-07 21:29 
AnswerRe: Dynamic table in sql Procedure? Pin
John-ph23-Oct-07 22:21
John-ph23-Oct-07 22:21 
GeneralRe: Dynamic table in sql Procedure? Pin
squattyarun23-Oct-07 22:55
squattyarun23-Oct-07 22:55 
QuestionProblem in creating a SSIS package Pin
hari1723-Oct-07 18:13
hari1723-Oct-07 18:13 
QuestionCopy Bulk Data into SQL Server Pin
Mehawitchi23-Oct-07 12:44
Mehawitchi23-Oct-07 12:44 
AnswerRe: Copy Bulk Data into SQL Server Pin
Rob Graham23-Oct-07 13:48
Rob Graham23-Oct-07 13:48 
GeneralRe: Copy Bulk Data into SQL Server Pin
Mehawitchi24-Oct-07 8:22
Mehawitchi24-Oct-07 8:22 
GeneralRe: Copy Bulk Data into SQL Server Pin
PIEBALDconsult24-Oct-07 17:13
mvePIEBALDconsult24-Oct-07 17:13 
QuestionSQL Pictures Pin
RevCuevas23-Oct-07 9:34
RevCuevas23-Oct-07 9:34 
AnswerRe: SQL Pictures Pin
pmarfleet23-Oct-07 10:29
pmarfleet23-Oct-07 10:29 
QuestionGet Script Pin
mehrdadc4823-Oct-07 8:58
mehrdadc4823-Oct-07 8:58 
AnswerRe: Get Script Pin
pmarfleet23-Oct-07 9:23
pmarfleet23-Oct-07 9:23 
QuestionDTS: Transform Task > Stored Procedure > Temp Table error Pin
Bjohnson3323-Oct-07 5:52
Bjohnson3323-Oct-07 5:52 
AnswerRe: DTS: Transform Task > Stored Procedure > Temp Table error Pin
jschell23-Oct-07 9:30
jschell23-Oct-07 9:30 
GeneralRe: DTS: Transform Task > Stored Procedure > Temp Table error Pin
Bjohnson3323-Oct-07 21:19
Bjohnson3323-Oct-07 21:19 
AnswerRe: DTS: Transform Task &amp;gt; Stored Procedure &amp;gt; Temp Table error [modified] Pin
GuyThiebaut23-Oct-07 10:26
professionalGuyThiebaut23-Oct-07 10:26 
GeneralRe: DTS: Transform Task &amp;gt; Stored Procedure &amp;gt; Temp Table error Pin
Bjohnson3323-Oct-07 21:21
Bjohnson3323-Oct-07 21:21 

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.