So this might just be a matter of me not knowing enough about Procedures, but I am trying to make a Procedure which update a Column in a Table to remove trailing spaces as it's a regular occurrence we are getting lately at work.
This is because we are in a transition phase from an old system to a new one, so we also made a new database to accompany this. The old Database used nvarchar nchar which means that even if you don't use all the slots for characters, it will fill the rest of the slots with spaces. In the new database though we use varchar so we want to get rid of white spaces!
So this is pretty handy:
UPDATE table SET column = LTRIM( RTRIM( column ) );
So I tried to make a Procedure out of it as we have to use it once in a while:
USE omitted
GO
CREATE PROCEDURE TrimTrailingSpaces
@table VARCHAR(50),
@column VARCHAR(50)
AS
BEGIN
UPDATE @table
SET
@column = LTRIM( RTRIM( @column ) );
END
GO
But whenever I try and execute this I get the error:
Msg 1087, Level 16, State 1, Procedure TrimTrailingSpaces, Line 6 [Batch Start Line 2]: Must declare the table variable "@table".
Is what I am doing just not possible?