Question:
is there a way to build a sql query dynamically and then execute it inside of a sql query?
Philip Augustus
2010-06-24 21:02:32 UTC
is there a way to build a sql query dynamically and then execute it inside of a sql query?
Three answers:
Ratchetr
2010-06-24 21:15:20 UTC
Yes, or at least, yes for every RDBMS system I've used.



But the exact syntax varies from 1 system to another.



Are you sure you need to do this? It's only the right solution for a really really small percentage of problems. And it does introduce some security issues (does any part of what you are going to exec come from user input?).



But, yeah, it can be done. Try a Google of 'your favorite RDMS' exec. Should get you started.
anonymous
2016-12-18 09:36:25 UTC
you additionally can attempt MySQL or according to threat SQLite (be cautious with this one.) there are countless sq. databases obtainable. nevertheless, there may be different problems worth investigating if stuff in basic terms isn't working. Are you constructive your RAM and hard force are in stable shape? Or are you attempting to actual question against your present oracle database? If it incredibly is corrupted, there is no longer something you're able to do in case you're actually not backing up. you are able to desire to attempt to make an outdoors application to question it as nicely. if that's the case, no different database will do something for you.
?
2010-06-24 21:05:35 UTC
This does the trick.



DECLARE strSQL VARCHAR(5000)

SET strSQL = 'select * from yourtable where fieldname=' ++ getdate()



exec strSQL


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...