Solved

syntax error in MSSQL Stored Procedure

Posted on 2011-02-15
6
269 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

     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 …
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 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

19 Experts available now in Live!

Get 1:1 Help Now