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.
| Author |
Topic |
|
mioara
Starting Member
3 Posts |
Posted - 2008-02-06 : 07:41:10
|
| Hi !I have the folowing statements in a stored procedure that creates a view :USE [Conel]goSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[CompletareDateIndexeOrare]ASBEGINSET NOCOUNT ON; if object_id('vIndexe') is not null drop view vIndexe CREATE VIEW vIndexe AS Select * from IndexeOrareZilniceENDWhen I try to save the procedure , I receive the following error message :Msg 156, Level 15, State 1, Procedure CompletareDateIndexeOrareIncorrect syntax near the keyword 'VIEW'.The statement with CREATE VIEW gives me this headaiche.If I try the statement in a new query, it's ok.So, which is my error, in the stored procedure ?Thanks,Mioara |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-02-06 : 07:44:21
|
| You cannot create a view within a stored procedure. Why would you want to do this?If you really need to do this, use dynamic sql. |
 |
|
|
|
|
|