Solved

syntax error in MSSQL Stored Procedure

Posted on 2011-02-15
6
279 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

717 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