Solved

syntax error in MSSQL Stored Procedure

Posted on 2011-02-15
6
271 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
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.

 

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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
using t-sql EXISTS 8 39
backups - Strategies 1 21
sql query Help 12 52
Backup databases and restore to another server -- how to alternate the chosen database? 7 26
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
A short film showing how OnPage and Connectwise integration works.

919 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

16 Experts available now in Live!

Get 1:1 Help Now