Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 T-SQL Stored Procedure Help

Author  Topic 

steve02a
Starting Member

2 Posts

Posted - 2006-04-01 : 18:53:52
I have a small sample table called CUSTOMER in a DB and it's here:

CustomerID Name Phone EmailAddress
1234 Bob Jones 9255551212 me@none.com
1235 Mary Jackson 4155551212 mary@mary.com
4567 Mark Franks 9258741588 mf@msn.com
6789 Joe Black 4085551212 joeb@msn.com

I'm trying to write this small stored procedure to recieve a new customer:
==================================
CREATE PROCEDURE Customer_Insert
@NewName varchar (50),
@NewPhone varchar (50),
@NewEmailAddress varchar (50),
AS
Select [Name], Phone, EmailAddress
FROM CUSTOMER
Where [Name] = @NewName, Phone = @NewPhone, EmailAddress = @NewEmailAddress
============================================

2nd SP I have also:
======================================
CREATE PROCEDURE Customer_Insert
(
@CustID varchar(4),
@NewName varchar (50),
@NewPhone varchar (50),
@NewEmailAddress varchar (50)
)
AS
INSERT INTO CUSTOMER
CustID, [Name], Phone, Where @CustID=Null, Name = @NewName, Phone = @NewPhone, EmailAddress = @NewEmailAddress
==================================================

I can't seem to get both these procedures to execute in query analyzer. My output is either:

Msg 156, Level 15, State 1, Procedure Customer_Insert, Line 5
Incorrect syntax near the keyword 'AS'.
Msg 156, Level 15, State 1, Procedure Customer_Insert, Line 7
Incorrect syntax near the keyword 'FROM'.

OR

Msg 102, Level 15, State 1, Procedure Customer_Insert, Line 10
Incorrect syntax near 'CustID'.

Does anyone know what's wrong w/it?

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-04-01 : 22:01:53
Where Clause syntax should be

Where [Name] = @NewName AND Phone = @NewPhone ...

But Not
Where [Name] = @NewName , Phone = @NewPhone ....

Also ur Insert Syntax is incorrect

Check the BOL or www.w3schools.com/sql fro correct SQL syntaxes

Srinika
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-04-01 : 23:30:20
Also check Book online samples how to work around with the basic SQL quries..

If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-03 : 01:48:55
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -