invalid stored procedures with CREATE TABLE inside
BluThing
Posts: 6
Hi,
the stored procedure
Is there a way to prevend sqlpromt from classifying them as invalid?
Thanks!
Lutz
the stored procedure
CREATE PROCEDURE test AS CREATE TABLE TMP ( somecolumn INT ) INSERT INTO TMP(somecolumn) VALUES (1)is discovered by sqlprompt as an invalid object though it can be stored and executed by SQL Server. We have a couple of procedures, wich create tables and remove them in the end.
Is there a way to prevend sqlpromt from classifying them as invalid?
Thanks!
Lutz
Comments
I tried to encapsulate this query:
But it works for me.
Can you please let mw know the steps I need to follow to reproduce this error?
Product Support
Redgate Software Ltd.
E-mail: support@red-gate.com
So I guess this is the better example, because it removes table TMP when finished:
There isn't anything else to be done than create it, start it and then look for inavlid objects.
spTest is always found to be invalid as long as table tmp doesn't exist.
I tried few things with this query and found that if you get rid of that first line to create Procedure it works fine.
If you add any other query before the code below and select the whole code to 'Encapsulate as SP' it should be fine.
Let me know if this explains the Prompt behaviour or not.
Product Support
Redgate Software Ltd.
E-mail: support@red-gate.com
I guess the reason it is showing your table <TMP> as invalid object is because it is not declared with # which will be considered as temporary table by SQL prompt and SQL Server. If you declare it as #TMP it will be ignored by SQL Prompt when finding invalid objects.
Hope this answers your question and I again apologise for the confusion.
Product Support
Redgate Software Ltd.
E-mail: support@red-gate.com
Sure, using a temporary table would solve my problem with SQL Prompt. Unfortunately there are some restrictions when using temporary tables with SQL Server. E.g. for debugging reasons we decided to use named tables.
A procedure that creates a table and then uses it, isn't really invalid. Is there no way for SQL Prompt to recognize this a valid or simply ignore it?[/quote]