bgreenhouse
Technical User
Hi there
I'm developing a page that updates a table through a stored procedure. Rather than just send the variables and plug them into the statement, I wanted to create the statement the web server and then send that string to the stored procedure. To avoid having a stored procedure that will simply execute any TSQL string that is sent it's way (probably a bad idea), I wanted to have UPDATE TABLENAME hardcoded into the stored procedure, along with the where part of the update clause. I figure that this should limit the amount of tampering that can be done through this sp. My problem is, I'm not quite sure how to concatenate and execute the TSQL string in the stored procedure. If I was in an ASP, I would simply concatenate the string and then execute it. How would I go about this in a stored procedure?
I have tried:
"UPDATE TABLENAME & @vTSQL1" (vTSQL1 is the SET part of the update command), planning to follow it with "& WHERE CARD_NUM = & @cCard_Num", but it doesn't like it (I know it's not quite right too, but can't figure out what to do). Is this sort of thing even possible?
Thanks
Ben
I'm developing a page that updates a table through a stored procedure. Rather than just send the variables and plug them into the statement, I wanted to create the statement the web server and then send that string to the stored procedure. To avoid having a stored procedure that will simply execute any TSQL string that is sent it's way (probably a bad idea), I wanted to have UPDATE TABLENAME hardcoded into the stored procedure, along with the where part of the update clause. I figure that this should limit the amount of tampering that can be done through this sp. My problem is, I'm not quite sure how to concatenate and execute the TSQL string in the stored procedure. If I was in an ASP, I would simply concatenate the string and then execute it. How would I go about this in a stored procedure?
I have tried:
"UPDATE TABLENAME & @vTSQL1" (vTSQL1 is the SET part of the update command), planning to follow it with "& WHERE CARD_NUM = & @cCard_Num", but it doesn't like it (I know it's not quite right too, but can't figure out what to do). Is this sort of thing even possible?
Thanks
Ben