Solved

syntax error in MSSQL Stored Procedure

Posted on 2011-02-15
6
274 Views
Last Modified: 2012-05-11
Hi,
Attached you will find a stored procedure. All I want to do is add a new column to the create table but it keeps complaining the column is invalid name.  I have tried different names but it still gives the error. Any help at this hour would be greatly appreciated.

Nigluc
code2.txt
0
Comment
Question by:Lucia
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:kraiven
ID: 34895208
what's the column name you are trying to add?
0
 
LVL 7

Accepted Solution

by:
mkobrin earned 250 total points
ID: 34895236
I can not see the name of the table you are creating:
create table
(  Emplid nvarchar (7) NOT NULL ,
   divisionID nvarchar (2)  NOT NULL ,...

Should it not be:
create table PS_Slic_Employee_Data
(  Emplid nvarchar (7) NOT NULL ,
   divisionID nvarchar (2)  NOT NULL ,...


If the table already exists, you will need to drop it first. I see you are truncating the table so the data loss in a drop table command will not be a problem
0
 
LVL 3

Assisted Solution

by:kraiven
kraiven earned 250 total points
ID: 34895241
Besides, you're missing a name for your table in the Create table script are you sure this isn't the actual cause of your error?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:Lucia
ID: 34895316
Hi,

I am trying to add  

Stat_Date datetime NOT NULL.   which is  for Start Date but I changed the name.

Sorry, I already had added the table name but did not put it in the upload.

Thanks,
Nigluc
0
 
LVL 3

Expert Comment

by:kraiven
ID: 34895345
so is the code you have attached the code that gives an error?

This works just fine for me, what is the exact error and are you certain it is due to the Create table?
create table MyTable
(  Emplid nvarchar (7) NOT NULL ,
   divisionID nvarchar (2)  NOT NULL ,
   Surname nvarchar (30) NOT NULL,
   First_Name nvarchar (30) NOT NULL,
   Term nvarchar (5) NOT NULL ,
   Course nvarchar (10)  NOT NULL ,
   SWF_Section_Size int NULL  ,
   Classification nvarchar(3), 
   End_Date datetime NOT NULL ,
   Start_Date datetime NOT NULL,
   Sect nvarchar (2) NULL ,
   Assigned_Teaching_Hours_TCH int NULL,
   Preparation nvarchar(3) Null,
   Evaluation nvarchar (3) NULL,
   TCW  int NOT Null,
   Course_Preps  int NULL,
   TCH_Sum int Null
)

Open in new window

0
 

Author Closing Comment

by:Lucia
ID: 34895354
Thank you to both,

I had renamed the table so the Table Create X was not the same as what I was inserting into and it gave a misleading error.

Nigluc
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

791 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