Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello all pro
excuse me for this question but i m a beginner i have this error when execute my stored procedure:
Incorrect syntax near the keyword 'Table'
this is my sp:

SQL
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE Sp_GetPersonVsFinanc
@source Table output
AS
BEGIN
	SET NOCOUNT ON;
	SELECT p.Id,p.Name,p.Family,f.DebtValue,f.BestankarValue
	into source
	from tbl_PersonInfo p join Financial f 
	on p.Id = f.FinancialPersonID
END
GO
Posted
Updated 29-Aug-12 21:35pm
v2
Comments
Rajesh Anuhya 30-Aug-12 3:35am    
Pre tags added.
--RA
daghune 30-Aug-12 3:39am    
CREATE PROCEDURE Sp_GetPersonVsFinanc
@source Table output
AS
BEGIN
SET NOCOUNT ON;
SELECT p.Id,p.Name,p.Family,f.DebtValue,f.BestankarValue
into source
from tbl_PersonInfo p join Financial f
on p.Id = f.FinancialPersonID
END

1 solution

Try this:
SQL
CREATE PROCEDURE Sp_GetPersonVsFinanc
AS
BEGIN
	SELECT p.Id,p.Name,p.Family,f.DebtValue,f.BestankarValue
	from tbl_PersonInfo p join Financial f 
	on p.Id = f.FinancialPersonID
END
GO

You don't suppose to add @source Table output, Select command will take care of returning records.


--Amit
 
Share this answer
 
v3
Comments
daghune 30-Aug-12 3:42am    
thank you _Amy
__TR__ 30-Aug-12 3:45am    
Hi,
I think the above 'select into' statement will create a 'source' table and give an error when it is executed again. So it would be better if we use #source.
SELECT p.Id,p.Name,p.Family,f.DebtValue,f.BestankarValue
into #source
from tbl_PersonInfo p join Financial f
on p.Id = f.FinancialPersonID

Also i think there is no point inserting it into another table, we can just query the tables and get the result. I hope i am making sense.
_Amy 30-Aug-12 4:46am    
Yes you are right. Now he can use the procedure easily. Thank you. :)
__TR__ 30-Aug-12 5:02am    
5ed!
daghune 30-Aug-12 5:50am    
thanks pro

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900