Does anybody know what the problem is? Thanks for your help!
CREATE PROCEDURE [dbo].[change] @id nvarchar(10), @week
nvarchar(10),@tbl nvarchar(10)
AS
BEGIN
DECLARE @strsql as nvarchar(500)
SET @strsql = N'UPDATE ' + @tbl + N' SET [status] = 3 WHERE ID = ' + @id
+ N' and [WEEK] = ' + @week
EXEC sp_executesql @cmd, @tbl, @id, @week
END
Yes, @cmd is not defined in your stored procedure.
-Eric Isaacs
EXEC sp_executesql @strsql;
On 8/25/09 3:40 PM, in article OLGSivbJ...@TK2MSFTNGP05.phx.gbl,
EXEC sp_executesql @strsql , @tbl, @id, @week
SET @strsql= N'UPDATE ' + @tbl + N' SET [status] = 3 WHERE ID = ''' +
@id + N''' and [WEEK] = ''' + @week + ''''
EXEC sp_executesql @strsql
Anyway, I strongly suggest some reading:
http://www.sommarskog.se/dynamic_sql.html
On 8/25/09 4:38 PM, in article #GnyDQcJ...@TK2MSFTNGP04.phx.gbl,
N'@id nvarchar(10), @week nvarchar(10)'
@tbl is not a parameter to the command, so there is no need to include it.
--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se
Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx