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.
| 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))ASINSERT INTO CUSTOMERCustID, [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 5Incorrect syntax near the keyword 'AS'.Msg 156, Level 15, State 1, Procedure Customer_Insert, Line 7Incorrect syntax near the keyword 'FROM'.ORMsg 102, Level 15, State 1, Procedure Customer_Insert, Line 10Incorrect 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 beWhere [Name] = @NewName AND Phone = @NewPhone ...But Not Where [Name] = @NewName , Phone = @NewPhone ....Also ur Insert Syntax is incorrectCheck the BOL or www.w3schools.com/sql fro correct SQL syntaxesSrinika |
 |
|
|
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. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|