kevinforbes
Programmer
Hi there,
I have the following stored procedure that I can't get to work, I think it's in how I declare the variables, any help would be appreciated.
CREATE PROCEDURE [dbo].[kf_sp_update_field] AS
DECLARE @up_tbl VARCHAR(50)
DECLARE @tbl2 VARCHAR(50)
DECLARE @set_field VARCHAR(50)
DECLARE @set_field_from VARCHAR(50)
DECLARE @src_tbl VARCHAR(50)
DECLARE @join_tbl VARCHAR(50)
DECLARE @join_val1 VARCHAR(50)
DECLARE @join_val2 VARCHAR(50)
SET @up_tbl = 'my_up_table_name'
SET @set_field = 'my_set_field'
SET @set_field_from = 'my_set_field_from'
SET @src_tbl = 'my_src_tbl_name'
SET @join_tbl = 'my_join_tbl_name'
SET @join_val1 = 'my_join_val1'
SET @join_val2 = 'my_join_val2'
Update @up_tbl
Set @set_field = @set_field_from
FROM @src_tbl INNER JOIN
@join_tbl ON @join_val1 = @join_val2
GO
Thanks,
Kev
I have the following stored procedure that I can't get to work, I think it's in how I declare the variables, any help would be appreciated.
CREATE PROCEDURE [dbo].[kf_sp_update_field] AS
DECLARE @up_tbl VARCHAR(50)
DECLARE @tbl2 VARCHAR(50)
DECLARE @set_field VARCHAR(50)
DECLARE @set_field_from VARCHAR(50)
DECLARE @src_tbl VARCHAR(50)
DECLARE @join_tbl VARCHAR(50)
DECLARE @join_val1 VARCHAR(50)
DECLARE @join_val2 VARCHAR(50)
SET @up_tbl = 'my_up_table_name'
SET @set_field = 'my_set_field'
SET @set_field_from = 'my_set_field_from'
SET @src_tbl = 'my_src_tbl_name'
SET @join_tbl = 'my_join_tbl_name'
SET @join_val1 = 'my_join_val1'
SET @join_val2 = 'my_join_val2'
Update @up_tbl
Set @set_field = @set_field_from
FROM @src_tbl INNER JOIN
@join_tbl ON @join_val1 = @join_val2
GO
Thanks,
Kev