What's wrong with this T-SQL? #1
In an effort to increase my T-SQL skills, and possibly help others learn T-SQL better, I'm kicking off a series of posts today that will show a T-SQL batch that has a problem with it, and after people have had ample time to try to solve the problem, I will post the answer.
For today's T-SQL problem, you have a table named 'Positions' that has two fields. 'Id' which is an int and is the primary key and identity field, and 'PositionValue' which is also a standard int field. A procedure to update a specific value for a PositionValue field (based on the Id value passed in) is shown below:
CREATE PROCEDURE UpdatePosition
(@PositionValue int,
@PositionId int
)
AS
SET NOCOUNT ON
GO
UPDATE
Positions
SET
PositionValue = @PositionValue
WHERE
Id = @PositionId
GO
Can you spot the problem?