I am trying to learn database on my own; all of your comments are appreciated. I have the following table.
CREATE TABLE AccountTable
(
AccountId INT IDENTITY(100,1) PRIMARY KEY,
FirstName NVARCHAR(50) NULL,
LastName NVARCHAR(50) NULL,
Street NVARCHAR(50) NULL,
StateId INT REFERENCES STATETABLE(StateId) NOT NULL
)
I would like to write a Stored procedure that updates the row. I imagine that the stored procedure would look something like this:
CREATE PROCEDURE AccountTable_Update
@Id INT,
@FirstName NVARCHAR(20),
@LastName NVARCHAR(20),
@StreetName NVARCHAR(20),
@StateId INT
AS
BEGIN
UPDATE AccountTable
Set FirstName = @FirstName
Set LastName = @LastName
Set Street = @StreetName
Set StateId = @StateId
WHERE AccountId = @Id
END
the caller provides the new information that he wants the row to have. I know that some of the fields are not entirely accurate or precise; I am doing this mostly for learning.
- I am having a syntax error with the SET commands in the UPDATE portion, and I don't know how to fix it.
- Is the stored procedure I am writing a procedure that you would write in real life? Is this an antipattern?
- Are there any grave errors I have made that just makes you cringe when you read the above TSQL?