Solved

SQL 2000 - Query Syntax Error

Posted on 2014-01-15
3
701 Views
Last Modified: 2014-01-15
Hello Experts,

I am getting this error on SQL Server 2000:

CREATE PROCEDURE dbo.AcpReport_HR_CoilProduction
      
AS
BEGIN
      
      SET NOCOUNT ON;
   
      DECLARE @Braze1Shift TABLE(SNo INT NOT NULL IDENTITY(1,1), JobTitle Varchar(255) NOT NULL ,   Name Varchar(255) NOT NULL ,  NUM Varchar(255) NOT NULL  );

      SET IDENTITY_INSERT @Braze1Shift ON;
      
      Insert Into @Braze1Shift(JobTitle,Name,NUM )
      SELECT JobTitle, LastName + ',' + FirstName as 'Name', NUM
      FROM [AIO_Test_Results].[dbo].[EmployeeInfo] Where [Group] = 'PRODUCTION'
      and Dept = 'BRAZE' and TRAIN IS NULL and Jobtitle <> 'LEAD' AND Shift = 1
      Order By LastName

      SET IDENTITY_INSERT @Braze1Shift OFF;

      Select * from @Braze1Shift;
   
   
END
GO



Error:

Msg 170, Level 15, State 1, Procedure AcpReport_HR_CoilProduction, Line 14
Line 14: Incorrect syntax near '@Braze1Shift'.

Msg 170, Level 15, State 1, Procedure AcpReport_HR_CoilProduction, Line 21
Line 21: Incorrect syntax near '@Braze1Shift'.
0
Comment
Question by:mani_sai
3 Comments
 
LVL 2

Accepted Solution

by:
Larso76 earned 500 total points
ID: 39782441
Change script to

CREATE PROCEDURE dbo.AcpReport_HR_CoilProduction
     
AS
BEGIN
     
      SET NOCOUNT ON;
   
     create TABLE #Braze1shift (SNo INT NOT NULL IDENTITY(1,1), JobTitle Varchar(255) NOT NULL ,   Name Varchar(255) NOT NULL ,  NUM Varchar(255) NOT NULL  );

      SET IDENTITY_INSERT Braze1Shift ON;
     
      Insert Into #Braze1shift(JobTitle,Name,NUM )
      SELECT JobTitle, LastName + ',' + FirstName as 'Name', NUM
      FROM [AIO_Test_Results].[dbo].[EmployeeInfo] Where [Group] = 'PRODUCTION'
      and Dept = 'BRAZE' and TRAIN IS NULL and Jobtitle <> 'LEAD' AND Shift = 1
      Order By LastName

      SET IDENTITY_INSERT #Braze1Shift OFF;

      Select * from #Braze1Shift;
   
   
END
GO
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 39782468
SQL 2000 doesn't have table variables. You need to use temporary tables as per the previous comment.
0
 
LVL 8

Author Closing Comment

by:mani_sai
ID: 39782487
Thanks
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now