Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using Declare in Stored Procedure

Status
Not open for further replies.

AgentM

MIS
Jun 6, 2001
387
US
Hi,
I am new to T-SQL and I am trying to use "declare" in a stored procedure. I am getting a syntax error not sure why, any help appreciated. Here's the code :-

Code:
ALTER PROCEDURE [dbo].[TOTALCOUNT] 
	@StartDate  DateTime,
    @EndDate	DateTime
AS
BEGIN
 SET NOCOUNT ON;
 DEclare @TOTALPEOPLE int, @TOTALMEN int
 SET @TOTALPEOPLE = 10000
 
  SELECT col1, @TOTALPEOPLE, @TOTALMENFROM TABLE1

END
 
The error is not on DECLARE it in query row:
This:
Code:
 SELECT col1, @TOTALPEOPLE, @TOTALMENFROM TABLE1
should be

Code:
 SELECT col1, @TOTALPEOPLE, @TOTALMENFROM [COLOR=red][b]FROM[/b][/color] TABLE1


Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
O, I forgot:
You should be very sure that TABLE1 exists in your current database where you create that SP.

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
the FROM was a typo.
I am getting a syntax error on line above the "SET NOCOUNT ON" line
 
Never mind got it. The error was a space in the var name in the Declare.
Thank you
 
:)
And I just saw that your FROM is there :)

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top