-
Validating a SQL statement
I`m writing a simple query builder to put into our application. I`d like to have SQL verify SELECT statements for me instead of having to check every little thing myself. In the Query Analyzer, I can get it to do this using
SET NOEXEC ON
SELECT * FROM bogustable
It will show an error if the SELECT statement is invalid. I can`t seem to get it to report this problem back from a stored proc. What I`m trying to do is something like
CREATE PROC CheckValid
@sql varchar(8000)
AS
SET NOEXEC ON
EXEC (@sql)
SET NOEXEC OFF
RETURN @@error
I always get a return value of 0. It seems that @@Error is getting cleared before EXEC ends.
Any ideas?
TIA,
Bill
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|