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)
 your urgent attention needed

Author  Topic 

pespes
Starting Member

6 Posts

Posted - 2008-07-30 : 05:19:49
hello all
i am new to writing stored procedures ...i have read a couple of books to that effect i have a challenge with writing this "insert prcoedure"


CREATE PROCEDURE db.appuserid
@username varchar(30)
@pwd varchar (20)

AS
--insert into login table
insert into login (username, pwd)
values
(@username
@pwd)

The error given is declare variable @username
and syntax error near pwd..

pls help me out
thanks in advance

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-07-30 : 05:29:19
Where is the comma?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

pespes
Starting Member

6 Posts

Posted - 2008-07-30 : 05:44:55
thanks,placed the comma there and it works

but i believe i can insert a lot of values on that same manner and it'll work
can u explain why declare is always there
what it is used for?


Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-30 : 07:30:34
quote:
Originally posted by pespes

thanks,placed the comma there and it works

but i believe i can insert a lot of values on that same manner and it'll work
can u explain why declare is always there
what it is used for?





Where did you use declare in the procedure?

Madhivanan

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

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-07-30 : 08:05:22
He probably means the parameters in the procedure header.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

pespes
Starting Member

6 Posts

Posted - 2008-07-30 : 11:22:17
there is a declare keyword ...that is usually used in sql and that was what i was talking about ...

how do i use the @@ error keyword i need examples...

thanks i advance
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-30 : 11:27:39
quote:
Originally posted by pespes

there is a declare keyword ...that is usually used in sql and that was what i was talking about ...

how do i use the @@ error keyword i need examples...

thanks i advance


Read it in SQL Server help file

Madhivanan

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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-30 : 13:43:53
quote:
Originally posted by pespes

there is a declare keyword ...that is usually used in sql and that was what i was talking about ...

how do i use the @@ error keyword i need examples...

thanks i advance


1.declare is used for declaration of variables in sql

http://doc.ddart.net/mssql/sql70/de-dz_2.htm

2. @@error returns the error number whenever error occurs. for syntax and usage example refer books online or

http://doc.ddart.net/mssql/sql70/globals_5.htm
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-30 : 13:45:09
Also make sure you search in books online before posting these type of questions in future.
Go to Top of Page
   

- Advertisement -