Solved

syntax error in MSSQL Stored Procedure

Posted on 2011-02-15
6
273 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Server Question 5 36
sql help 8 55
SSAS Hierarchy with columns with folder names 10 14
Job - date manual 1 23
In this article I will describe the Backup & Restore 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.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

832 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