Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert in a Stored Proc with a Where clause

Status
Not open for further replies.

craigfw

Technical User
Aug 11, 2004
32
US
Hey everyone hope Friday is going well!

I have to declare that I am a DBA returning to the field after an 8 year break, and this time I'm trying to learn SQL. I have a problem with this query that we are going to exec from a Web front end to update a site User login/validation table where the username and password are sent after their login information is verified . The basic Insert works to , but when I try to create the stored proc, then it won't create and has a problem with the WHERE clause. What am I doing wrong?

--------------------------------------------------------

CREATE PROCEDURE sp_Insert_Register_Table_UserandPassword

@ID int,
@username char(30),
@password char(30)

AS

UPDATE Register (username, password)

VALUES (@username,@password)

WHERE ID = @ID
 
UPDATE Register
SET username=@username, password=@password
WHERE ID = @ID

Also: if you have variable-length data (as username/password usually are), use varchar data type rather than char.
 
Thanks that worked well and it's so simple and articulate. Appreciate your help! I didn't create the tables as I was hired to come in an be their DBA after they knew they were over their heads, but we're not so far along that I can't alter them.

Craig Webber
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top