JeffCarlin
Programmer
We use a "update" app to update the db in a VB app. The update app applies db patches as needed, such as ALTER TABLE, CREATE TABLE, etc. We also use it to CREATE PROCEDURE. This all works well until our new procedure contains quotes to handle varying params, such as:
This SP will work if we just create it in the Enterprise Manager, but if we try it thru VB, it won't get created. We just create a long string by concatenating a bunch of smaller strings. Each line you see above is a small string. Once we concatenate them and insert a CHR(13) after each line, we attempt to EXECUTE and that's where the failure occurs.
Thanks for any help you can give.
Code:
CREATE PROCEDURE tlcselection_findtemplatename
@Parm1 varchar(50), -- Table Name
@Parm2 varchar(11),
@Parm3 varchar(2)
AS
DECLARE @stg varchar(500)
SET @stg =
"SELECT " + @Parm1 + ".strTemplateName " +
"FROM " + @Parm1 + ", tblTLC_Header " +
"WHERE " + @Parm1 + ".lngTemplateID = tblTLC_Header.lngOrigTemplateID " +
"AND tblTLC_Header.strPatSSN = '" + @Parm2 + "' " +
"AND tblTLC_Header.strPatTreatNum = '" + @Parm3 + "'"
EXECUTE (@stg)
GO
Thanks for any help you can give.