Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Create View and Procedure must be first statements

Author  Topic 

Wanderer
Master Smack Fu Yak Hacker

1168 Posts

Posted - 2005-06-24 : 04:25:33
Does anyone know why stored procedure's and views need to be
quote:

'CREATE VIEW' must be the first statement in a query batch.



And yet tables, indexes, constraints and many other system objects can be created one after the other...

I just can't figure it out

Oh well

*##* *##* *##* *##*

Chaos, Disorder and Panic ... my work is done here!

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-24 : 05:43:19
That is the Standard
What forces you to ask this question?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Wanderer
Master Smack Fu Yak Hacker

1168 Posts

Posted - 2005-06-24 : 08:37:45
Nothing forces me .. I was just interested if there was a technical reason behind why SQL Server does this.

Several of our rollout scripts have changes in them, and our "template" does reporting on environment where the script is run, start time and end time, and run time etc. Run time is generated by subtracting start time, which was stored in a variable, from end time.

I know that when run from QA, you can see the run time, but the idea is that these reports are saved, and with their displays the details what was done, where, and how long it took, for example:


Start point of script: Create PartyProductAudit table to cater for Link and Delink history rows

--------------------------------------------------
Run on SQL Server : OPSWS148


------------- ------------------------------------------------------
Run on date : 2005-06-24 14:33:08.703

Start of Script : 2005-06-24 14:33:08.703
Create Reference Table
Table : AuditActionType does not exist - it will be created
Table : AuditActionType has been created
Create Instance Table
Table : PartyProductAudit does not exist - it will be created
Table : PartyProductAudit has been created
End of Script. Runtime was : 1 seconds


Obviously, batch terminator means I lose my Start time, hence cannot create run times.

This is NOT a critical issue - we will run the creation of the VIEWS etc. without the Run Time of the template, but it raised the question in my mind as to why it was being done.

*##* *##* *##* *##*

Chaos, Disorder and Panic ... my work is done here!
Go to Top of Page
   

- Advertisement -