Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing SQL or sp's in Stored Proc

Status
Not open for further replies.

LokiDba

Programmer
Dec 13, 2000
63
GB
Hi,

I'm currently building a utility stored proc that is
to output the results of a SQL statement or a stored
procedure to a file.

The problem I have is parsing the SQL statement. In Oracle
I'd just call the DBMS_SQL.Parse function. Is there something similiar is SQL Server 2000 or will I have to
use SET PARSEONLY in the stored proc and see if I get
an error message or not.

Thanks in Advance


LokiDBA
 
Hi,

I amnot sure if I get you right.
You want to pass a SQL-statement as a parameter to a stored procedure and then execute that statement?

EXEC sp_ExecuteSql @SQLStatement

should be able to do that.
you can use bcp to write to file.

Ah, I read your question again, you want to check the SQL-statement before you execute it?
Hmm, then I cannot help you any further. Good luck!

Branko
 
Yes thats right I need to check the SQL statement for correctness first then execute it

LokiDBA
 
Hi,

as I said, I cannot offer much help
I just read that you shouldn't use SET PARSEONLY in a stored procedure.

I don't know from where the SQL statement will come, but it might be a good idea to parse and check the statement yourself because of security reasons (prohibit use of xp_commandshell etc.)

Branko
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top