SQL Server has Deferred Name Resolution, means you can address tables which currently don't exists, but the SQL syntax must be correct.
It's possibile create a stored procedure without check sintax or code?
Hi I know seems a little bit strange..
but I'm only curious about...
basically I would like to create a stored in a DB like:
CREATE PROCEDURE [dbo].[rpt_Fatt]
as
BEGIN
SELECT bla from bla
END
Obviously I got:
Must declare the scalar variable "@Source Technology ".
Msg 102, Level 15, State 1, Procedure rpt_Fatt, Line 180 [Batch Start Line 9]
Incorrect syntax near ','.
but I know ...
only if it'is possible to SET a RUN AND CREATE without check.
Thanks ALen
2 additional answers
Sort by: Most helpful
-
Erland Sommarskog 115.5K Reputation points MVP
2020-12-03T22:43:45.937+00:00 No, that is not possible. The procedure you create must be syntactically correct. It must also pass binding. That is, all columns in known tables must exist. However, if a query refers to a non-existing table, this will be suppressed, and so will other binding errors in that query.
All source code should be stored on disk and be under version control. In that case, there is no reason to store unfinished code in the database.
-
EchoLiu-MSFT 14,591 Reputation points
2020-12-04T06:09:40.337+00:00 Hi @Alen Cappelletti ,
When you execute arbitrary code in ssms, ssms will automatically check the syntax. If your grammar is incorrect, your execution will not succeed.
So each piece of your code must have complete and correct syntax.
Of course, you can simplify the code as much as possible. You only need to write the basic syntax requirements.If you have any question, please feel free to let me know.
If the response is helpful, please click "Accept Answer" and upvote it.Regards
Echo
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hot issues November--What can I do if my transaction log is full?
Hot issues November--How to convert Profiler trace into a SQL Server table