sql statement
-
CREATE PROCEDURE pr_InsertDictTable @intID int, @vchrValue nvarchar(50), @vchrWesBarCode nvarchar(10), @vchrTableName varchar(20) AS declare @sql varchar(1000) set @sql = 'INSERT INTO ' + @vchrTableName + ' (Id, Name, PDACode) VALUES ( '+@intID+','+@vchrValue+','+@vchrWesBarCode+')' print @sql GO Any problem in this procedure? ====== You need a head to program. Cool, fast and sharp.
-
CREATE PROCEDURE pr_InsertDictTable @intID int, @vchrValue nvarchar(50), @vchrWesBarCode nvarchar(10), @vchrTableName varchar(20) AS declare @sql varchar(1000) set @sql = 'INSERT INTO ' + @vchrTableName + ' (Id, Name, PDACode) VALUES ( '+@intID+','+@vchrValue+','+@vchrWesBarCode+')' print @sql GO Any problem in this procedure? ====== You need a head to program. Cool, fast and sharp.
-
CREATE PROCEDURE pr_InsertDictTable @intID int, @vchrValue nvarchar(50), @vchrWesBarCode nvarchar(10), @vchrTableName varchar(20) AS declare @sql varchar(1000) set @sql = 'INSERT INTO ' + @vchrTableName + ' (Id, Name, PDACode) VALUES ( '+@intID+','+@vchrValue+','+@vchrWesBarCode+')' print @sql GO Any problem in this procedure? ====== You need a head to program. Cool, fast and sharp.
Yes, plenty. 1. It's pointless. All you're doing is printing a string. Why not just generate the string at the caller? 2. variable @sql is not needed. you could just "print 'insert into ... " 3. It won't work. You need to CONVERT(varchar(10),@intid) before you can use it as a varchar. 4. You're mixing nvarchar and varchar. and implicitly casting nvarchar to varchar, thus negating the whole point of using nvarchar in the first place. 5. I think hungarian notation in a database is evil. 6. The main point of stored procedures is that they're compiled and hence more efficient. You're not leveraging that efficiency at all here. jon
#include <beer.h>