Bonjour,
Je souhaite créer une vue si elle n'existe pas déjà, ou la modifier sinon.
J'ai pensé à faire comme ça par exemple :
if exists (select * from dbo.sysobjects where id > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
ALTER VIEW ViewTOTO AS SELECT ...
else
CREATE VIEW ViewTOTO AS SELECT ...
Mais apparamment, seul DROP est autorisé après le test if, sauf pour les
tables.
Alors y a-t-il un autre moyen de faire ?
Merci d'avance
Yan
Bonjour,
Je souhaite créer une vue si elle n'existe pas déjà, ou la modifier sinon.
J'ai pensé à faire comme ça par exemple :
if exists (select * from dbo.sysobjects where id > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
ALTER VIEW ViewTOTO AS SELECT ...
else
CREATE VIEW ViewTOTO AS SELECT ...
Mais apparamment, seul DROP est autorisé après le test if, sauf pour les
tables.
Alors y a-t-il un autre moyen de faire ?
Merci d'avance
Yan
Bonjour,
Je souhaite créer une vue si elle n'existe pas déjà, ou la modifier sinon.
J'ai pensé à faire comme ça par exemple :
if exists (select * from dbo.sysobjects where id > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
ALTER VIEW ViewTOTO AS SELECT ...
else
CREATE VIEW ViewTOTO AS SELECT ...
Mais apparamment, seul DROP est autorisé après le test if, sauf pour les
tables.
Alors y a-t-il un autre moyen de faire ?
Merci d'avance
Yan
Bonjour,
if exists (select * from dbo.sysobjects where id > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
BEGIN
ALTER VIEW ViewTOTO AS SELECT ...
END
else
BEGIN
CREATE VIEW ViewTOTO AS SELECT ...
END
Phil.
________________________________________________________
Philippe TROTIN http://blogs.msdn.com/ptrotin
Microsoft Services France http://www.microsoft.com/france
"Yan" wrote in message
news:41c98d40$0$12848$
> Bonjour,
>
> Je souhaite créer une vue si elle n'existe pas déjà, ou la modifier
>
> J'ai pensé à faire comme ça par exemple :
>
> if exists (select * from dbo.sysobjects where id > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
> ALTER VIEW ViewTOTO AS SELECT ...
> else
> CREATE VIEW ViewTOTO AS SELECT ...
>
> Mais apparamment, seul DROP est autorisé après le test if, sauf pour les
> tables.
>
> Alors y a-t-il un autre moyen de faire ?
>
> Merci d'avance
>
> Yan
>
>
Bonjour,
if exists (select * from dbo.sysobjects where id > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
BEGIN
ALTER VIEW ViewTOTO AS SELECT ...
END
else
BEGIN
CREATE VIEW ViewTOTO AS SELECT ...
END
Phil.
________________________________________________________
Philippe TROTIN http://blogs.msdn.com/ptrotin
Microsoft Services France http://www.microsoft.com/france
"Yan" <yan@nepasrepondre.com> wrote in message
news:41c98d40$0$12848$8fcfb975@news.wanadoo.fr...
> Bonjour,
>
> Je souhaite créer une vue si elle n'existe pas déjà, ou la modifier
>
> J'ai pensé à faire comme ça par exemple :
>
> if exists (select * from dbo.sysobjects where id > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
> ALTER VIEW ViewTOTO AS SELECT ...
> else
> CREATE VIEW ViewTOTO AS SELECT ...
>
> Mais apparamment, seul DROP est autorisé après le test if, sauf pour les
> tables.
>
> Alors y a-t-il un autre moyen de faire ?
>
> Merci d'avance
>
> Yan
>
>
Bonjour,
if exists (select * from dbo.sysobjects where id > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
BEGIN
ALTER VIEW ViewTOTO AS SELECT ...
END
else
BEGIN
CREATE VIEW ViewTOTO AS SELECT ...
END
Phil.
________________________________________________________
Philippe TROTIN http://blogs.msdn.com/ptrotin
Microsoft Services France http://www.microsoft.com/france
"Yan" wrote in message
news:41c98d40$0$12848$
> Bonjour,
>
> Je souhaite créer une vue si elle n'existe pas déjà, ou la modifier
>
> J'ai pensé à faire comme ça par exemple :
>
> if exists (select * from dbo.sysobjects where id > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
> ALTER VIEW ViewTOTO AS SELECT ...
> else
> CREATE VIEW ViewTOTO AS SELECT ...
>
> Mais apparamment, seul DROP est autorisé après le test if, sauf pour les
> tables.
>
> Alors y a-t-il un autre moyen de faire ?
>
> Merci d'avance
>
> Yan
>
>
Nan nan, ALTER ou CREATE VIEW ne sont pas possible après les test IF
"Philippe T [MS]" a écrit dans le message
news:
> Bonjour,
>
> if exists (select * from dbo.sysobjects where id > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
> BEGIN
> ALTER VIEW ViewTOTO AS SELECT ...
> END
> else
> BEGIN
> CREATE VIEW ViewTOTO AS SELECT ...
> END
>
> Phil.
> ________________________________________________________
> Philippe TROTIN http://blogs.msdn.com/ptrotin
> Microsoft Services France http://www.microsoft.com/france
>
> "Yan" wrote in message
> news:41c98d40$0$12848$
> > Bonjour,
> >
> > Je souhaite créer une vue si elle n'existe pas déjà, ou la modifier
sinon.
> >
> > J'ai pensé à faire comme ça par exemple :
> >
> > if exists (select * from dbo.sysobjects where id > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
> > ALTER VIEW ViewTOTO AS SELECT ...
> > else
> > CREATE VIEW ViewTOTO AS SELECT ...
> >
> > Mais apparamment, seul DROP est autorisé après le test if, sauf pour
> > tables.
> >
> > Alors y a-t-il un autre moyen de faire ?
> >
> > Merci d'avance
> >
> > Yan
> >
> >
>
>
Nan nan, ALTER ou CREATE VIEW ne sont pas possible après les test IF
"Philippe T [MS]" <ptrotin@online.microsoft.com> a écrit dans le message
news:OeqAvqE6EHA.3076@TK2MSFTNGP15.phx.gbl...
> Bonjour,
>
> if exists (select * from dbo.sysobjects where id > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
> BEGIN
> ALTER VIEW ViewTOTO AS SELECT ...
> END
> else
> BEGIN
> CREATE VIEW ViewTOTO AS SELECT ...
> END
>
> Phil.
> ________________________________________________________
> Philippe TROTIN http://blogs.msdn.com/ptrotin
> Microsoft Services France http://www.microsoft.com/france
>
> "Yan" <yan@nepasrepondre.com> wrote in message
> news:41c98d40$0$12848$8fcfb975@news.wanadoo.fr...
> > Bonjour,
> >
> > Je souhaite créer une vue si elle n'existe pas déjà, ou la modifier
sinon.
> >
> > J'ai pensé à faire comme ça par exemple :
> >
> > if exists (select * from dbo.sysobjects where id > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
> > ALTER VIEW ViewTOTO AS SELECT ...
> > else
> > CREATE VIEW ViewTOTO AS SELECT ...
> >
> > Mais apparamment, seul DROP est autorisé après le test if, sauf pour
> > tables.
> >
> > Alors y a-t-il un autre moyen de faire ?
> >
> > Merci d'avance
> >
> > Yan
> >
> >
>
>
Nan nan, ALTER ou CREATE VIEW ne sont pas possible après les test IF
"Philippe T [MS]" a écrit dans le message
news:
> Bonjour,
>
> if exists (select * from dbo.sysobjects where id > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
> BEGIN
> ALTER VIEW ViewTOTO AS SELECT ...
> END
> else
> BEGIN
> CREATE VIEW ViewTOTO AS SELECT ...
> END
>
> Phil.
> ________________________________________________________
> Philippe TROTIN http://blogs.msdn.com/ptrotin
> Microsoft Services France http://www.microsoft.com/france
>
> "Yan" wrote in message
> news:41c98d40$0$12848$
> > Bonjour,
> >
> > Je souhaite créer une vue si elle n'existe pas déjà, ou la modifier
sinon.
> >
> > J'ai pensé à faire comme ça par exemple :
> >
> > if exists (select * from dbo.sysobjects where id > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
> > ALTER VIEW ViewTOTO AS SELECT ...
> > else
> > CREATE VIEW ViewTOTO AS SELECT ...
> >
> > Mais apparamment, seul DROP est autorisé après le test if, sauf pour
> > tables.
> >
> > Alors y a-t-il un autre moyen de faire ?
> >
> > Merci d'avance
> >
> > Yan
> >
> >
>
>
Bonjour,
if exists (select * from dbo.sysobjects where id > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
BEGIN
ALTER VIEW ViewTOTO AS SELECT ...
END
else
BEGIN
CREATE VIEW ViewTOTO AS SELECT ...
END
Phil.
________________________________________________________
Philippe TROTIN http://blogs.msdn.com/ptrotin
Microsoft Services France http://www.microsoft.com/france
"Yan" wrote in message
news:41c98d40$0$12848$
> Bonjour,
>
> Je souhaite créer une vue si elle n'existe pas déjà, ou la modifier
>
> J'ai pensé à faire comme ça par exemple :
>
> if exists (select * from dbo.sysobjects where id > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
> ALTER VIEW ViewTOTO AS SELECT ...
> else
> CREATE VIEW ViewTOTO AS SELECT ...
>
> Mais apparamment, seul DROP est autorisé après le test if, sauf pour les
> tables.
>
> Alors y a-t-il un autre moyen de faire ?
>
> Merci d'avance
>
> Yan
>
>
Bonjour,
if exists (select * from dbo.sysobjects where id > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
BEGIN
ALTER VIEW ViewTOTO AS SELECT ...
END
else
BEGIN
CREATE VIEW ViewTOTO AS SELECT ...
END
Phil.
________________________________________________________
Philippe TROTIN http://blogs.msdn.com/ptrotin
Microsoft Services France http://www.microsoft.com/france
"Yan" <yan@nepasrepondre.com> wrote in message
news:41c98d40$0$12848$8fcfb975@news.wanadoo.fr...
> Bonjour,
>
> Je souhaite créer une vue si elle n'existe pas déjà, ou la modifier
>
> J'ai pensé à faire comme ça par exemple :
>
> if exists (select * from dbo.sysobjects where id > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
> ALTER VIEW ViewTOTO AS SELECT ...
> else
> CREATE VIEW ViewTOTO AS SELECT ...
>
> Mais apparamment, seul DROP est autorisé après le test if, sauf pour les
> tables.
>
> Alors y a-t-il un autre moyen de faire ?
>
> Merci d'avance
>
> Yan
>
>
Bonjour,
if exists (select * from dbo.sysobjects where id > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
BEGIN
ALTER VIEW ViewTOTO AS SELECT ...
END
else
BEGIN
CREATE VIEW ViewTOTO AS SELECT ...
END
Phil.
________________________________________________________
Philippe TROTIN http://blogs.msdn.com/ptrotin
Microsoft Services France http://www.microsoft.com/france
"Yan" wrote in message
news:41c98d40$0$12848$
> Bonjour,
>
> Je souhaite créer une vue si elle n'existe pas déjà, ou la modifier
>
> J'ai pensé à faire comme ça par exemple :
>
> if exists (select * from dbo.sysobjects where id > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
> ALTER VIEW ViewTOTO AS SELECT ...
> else
> CREATE VIEW ViewTOTO AS SELECT ...
>
> Mais apparamment, seul DROP est autorisé après le test if, sauf pour les
> tables.
>
> Alors y a-t-il un autre moyen de faire ?
>
> Merci d'avance
>
> Yan
>
>
Bonjour,
Alors, créer une chaine de caractère @SQL = N'ALTER VIEW ViewTOTO AS
...'
et utiliserun EXEC sp_executesql @SQL...
Phil.
________________________________________________________
Philippe TROTIN http://blogs.msdn.com/ptrotin
Microsoft Services France http://www.microsoft.com/france
"Yan" wrote in message
news:41cac9fe$0$30803$
> Nan nan, ALTER ou CREATE VIEW ne sont pas possible après les test IF
>
>
>
>
> "Philippe T [MS]" a écrit dans le message
de
> news:
> > Bonjour,
> >
> > if exists (select * from dbo.sysobjects where id > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
> > BEGIN
> > ALTER VIEW ViewTOTO AS SELECT ...
> > END
> > else
> > BEGIN
> > CREATE VIEW ViewTOTO AS SELECT ...
> > END
> >
> > Phil.
> > ________________________________________________________
> > Philippe TROTIN http://blogs.msdn.com/ptrotin
> > Microsoft Services France http://www.microsoft.com/france
> >
> > "Yan" wrote in message
> > news:41c98d40$0$12848$
> > > Bonjour,
> > >
> > > Je souhaite créer une vue si elle n'existe pas déjà, ou la modifier
> sinon.
> > >
> > > J'ai pensé à faire comme ça par exemple :
> > >
> > > if exists (select * from dbo.sysobjects where id > > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') 1)
> > > ALTER VIEW ViewTOTO AS SELECT ...
> > > else
> > > CREATE VIEW ViewTOTO AS SELECT ...
> > >
> > > Mais apparamment, seul DROP est autorisé après le test if, sauf pour
les
> > > tables.
> > >
> > > Alors y a-t-il un autre moyen de faire ?
> > >
> > > Merci d'avance
> > >
> > > Yan
> > >
> > >
> >
> >
>
>
Bonjour,
Alors, créer une chaine de caractère @SQL = N'ALTER VIEW ViewTOTO AS
...'
et utiliserun EXEC sp_executesql @SQL...
Phil.
________________________________________________________
Philippe TROTIN http://blogs.msdn.com/ptrotin
Microsoft Services France http://www.microsoft.com/france
"Yan" <yan@nepasrepondre.com> wrote in message
news:41cac9fe$0$30803$8fcfb975@news.wanadoo.fr...
> Nan nan, ALTER ou CREATE VIEW ne sont pas possible après les test IF
>
>
>
>
> "Philippe T [MS]" <ptrotin@online.microsoft.com> a écrit dans le message
de
> news:OeqAvqE6EHA.3076@TK2MSFTNGP15.phx.gbl...
> > Bonjour,
> >
> > if exists (select * from dbo.sysobjects where id > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
> > BEGIN
> > ALTER VIEW ViewTOTO AS SELECT ...
> > END
> > else
> > BEGIN
> > CREATE VIEW ViewTOTO AS SELECT ...
> > END
> >
> > Phil.
> > ________________________________________________________
> > Philippe TROTIN http://blogs.msdn.com/ptrotin
> > Microsoft Services France http://www.microsoft.com/france
> >
> > "Yan" <yan@nepasrepondre.com> wrote in message
> > news:41c98d40$0$12848$8fcfb975@news.wanadoo.fr...
> > > Bonjour,
> > >
> > > Je souhaite créer une vue si elle n'existe pas déjà, ou la modifier
> sinon.
> > >
> > > J'ai pensé à faire comme ça par exemple :
> > >
> > > if exists (select * from dbo.sysobjects where id > > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') 1)
> > > ALTER VIEW ViewTOTO AS SELECT ...
> > > else
> > > CREATE VIEW ViewTOTO AS SELECT ...
> > >
> > > Mais apparamment, seul DROP est autorisé après le test if, sauf pour
les
> > > tables.
> > >
> > > Alors y a-t-il un autre moyen de faire ?
> > >
> > > Merci d'avance
> > >
> > > Yan
> > >
> > >
> >
> >
>
>
Bonjour,
Alors, créer une chaine de caractère @SQL = N'ALTER VIEW ViewTOTO AS
...'
et utiliserun EXEC sp_executesql @SQL...
Phil.
________________________________________________________
Philippe TROTIN http://blogs.msdn.com/ptrotin
Microsoft Services France http://www.microsoft.com/france
"Yan" wrote in message
news:41cac9fe$0$30803$
> Nan nan, ALTER ou CREATE VIEW ne sont pas possible après les test IF
>
>
>
>
> "Philippe T [MS]" a écrit dans le message
de
> news:
> > Bonjour,
> >
> > if exists (select * from dbo.sysobjects where id > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') = 1)
> > BEGIN
> > ALTER VIEW ViewTOTO AS SELECT ...
> > END
> > else
> > BEGIN
> > CREATE VIEW ViewTOTO AS SELECT ...
> > END
> >
> > Phil.
> > ________________________________________________________
> > Philippe TROTIN http://blogs.msdn.com/ptrotin
> > Microsoft Services France http://www.microsoft.com/france
> >
> > "Yan" wrote in message
> > news:41c98d40$0$12848$
> > > Bonjour,
> > >
> > > Je souhaite créer une vue si elle n'existe pas déjà, ou la modifier
> sinon.
> > >
> > > J'ai pensé à faire comme ça par exemple :
> > >
> > > if exists (select * from dbo.sysobjects where id > > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') 1)
> > > ALTER VIEW ViewTOTO AS SELECT ...
> > > else
> > > CREATE VIEW ViewTOTO AS SELECT ...
> > >
> > > Mais apparamment, seul DROP est autorisé après le test if, sauf pour
les
> > > tables.
> > >
> > > Alors y a-t-il un autre moyen de faire ?
> > >
> > > Merci d'avance
> > >
> > > Yan
> > >
> > >
> >
> >
>
>
Ca c'est une bonne idée !
J'ai essayé, ça marche bien
Merci
"Philippe T [MS]" a écrit dans le message
news:
> Bonjour,
>
> Alors, créer une chaine de caractère @SQL = N'ALTER VIEW ViewTOTO AS
SELECT
> ...'
>
> et utiliserun EXEC sp_executesql @SQL...
>
> Phil.
> ________________________________________________________
> Philippe TROTIN http://blogs.msdn.com/ptrotin
> Microsoft Services France http://www.microsoft.com/france
>
> "Yan" wrote in message
> news:41cac9fe$0$30803$
> > Nan nan, ALTER ou CREATE VIEW ne sont pas possible après les test IF
> >
> >
> >
> >
> > "Philippe T [MS]" a écrit dans le
> de
> > news:
> > > Bonjour,
> > >
> > > if exists (select * from dbo.sysobjects where id > > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') 1)
> > > BEGIN
> > > ALTER VIEW ViewTOTO AS SELECT ...
> > > END
> > > else
> > > BEGIN
> > > CREATE VIEW ViewTOTO AS SELECT ...
> > > END
> > >
> > > Phil.
> > > ________________________________________________________
> > > Philippe TROTIN
> > > Microsoft Services France http://www.microsoft.com/france
> > >
> > > "Yan" wrote in message
> > > news:41c98d40$0$12848$
> > > > Bonjour,
> > > >
> > > > Je souhaite créer une vue si elle n'existe pas déjà, ou la
> > sinon.
> > > >
> > > > J'ai pensé à faire comme ça par exemple :
> > > >
> > > > if exists (select * from dbo.sysobjects where id > > > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') > 1)
> > > > ALTER VIEW ViewTOTO AS SELECT ...
> > > > else
> > > > CREATE VIEW ViewTOTO AS SELECT ...
> > > >
> > > > Mais apparamment, seul DROP est autorisé après le test if, sauf
> les
> > > > tables.
> > > >
> > > > Alors y a-t-il un autre moyen de faire ?
> > > >
> > > > Merci d'avance
> > > >
> > > > Yan
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Ca c'est une bonne idée !
J'ai essayé, ça marche bien
Merci
"Philippe T [MS]" <ptrotin@online.microsoft.com> a écrit dans le message
news:OR6ZZoP6EHA.4008@TK2MSFTNGP15.phx.gbl...
> Bonjour,
>
> Alors, créer une chaine de caractère @SQL = N'ALTER VIEW ViewTOTO AS
SELECT
> ...'
>
> et utiliserun EXEC sp_executesql @SQL...
>
> Phil.
> ________________________________________________________
> Philippe TROTIN http://blogs.msdn.com/ptrotin
> Microsoft Services France http://www.microsoft.com/france
>
> "Yan" <yan@nepasrepondre.com> wrote in message
> news:41cac9fe$0$30803$8fcfb975@news.wanadoo.fr...
> > Nan nan, ALTER ou CREATE VIEW ne sont pas possible après les test IF
> >
> >
> >
> >
> > "Philippe T [MS]" <ptrotin@online.microsoft.com> a écrit dans le
> de
> > news:OeqAvqE6EHA.3076@TK2MSFTNGP15.phx.gbl...
> > > Bonjour,
> > >
> > > if exists (select * from dbo.sysobjects where id > > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') 1)
> > > BEGIN
> > > ALTER VIEW ViewTOTO AS SELECT ...
> > > END
> > > else
> > > BEGIN
> > > CREATE VIEW ViewTOTO AS SELECT ...
> > > END
> > >
> > > Phil.
> > > ________________________________________________________
> > > Philippe TROTIN
> > > Microsoft Services France http://www.microsoft.com/france
> > >
> > > "Yan" <yan@nepasrepondre.com> wrote in message
> > > news:41c98d40$0$12848$8fcfb975@news.wanadoo.fr...
> > > > Bonjour,
> > > >
> > > > Je souhaite créer une vue si elle n'existe pas déjà, ou la
> > sinon.
> > > >
> > > > J'ai pensé à faire comme ça par exemple :
> > > >
> > > > if exists (select * from dbo.sysobjects where id > > > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') > 1)
> > > > ALTER VIEW ViewTOTO AS SELECT ...
> > > > else
> > > > CREATE VIEW ViewTOTO AS SELECT ...
> > > >
> > > > Mais apparamment, seul DROP est autorisé après le test if, sauf
> les
> > > > tables.
> > > >
> > > > Alors y a-t-il un autre moyen de faire ?
> > > >
> > > > Merci d'avance
> > > >
> > > > Yan
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Ca c'est une bonne idée !
J'ai essayé, ça marche bien
Merci
"Philippe T [MS]" a écrit dans le message
news:
> Bonjour,
>
> Alors, créer une chaine de caractère @SQL = N'ALTER VIEW ViewTOTO AS
SELECT
> ...'
>
> et utiliserun EXEC sp_executesql @SQL...
>
> Phil.
> ________________________________________________________
> Philippe TROTIN http://blogs.msdn.com/ptrotin
> Microsoft Services France http://www.microsoft.com/france
>
> "Yan" wrote in message
> news:41cac9fe$0$30803$
> > Nan nan, ALTER ou CREATE VIEW ne sont pas possible après les test IF
> >
> >
> >
> >
> > "Philippe T [MS]" a écrit dans le
> de
> > news:
> > > Bonjour,
> > >
> > > if exists (select * from dbo.sysobjects where id > > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') 1)
> > > BEGIN
> > > ALTER VIEW ViewTOTO AS SELECT ...
> > > END
> > > else
> > > BEGIN
> > > CREATE VIEW ViewTOTO AS SELECT ...
> > > END
> > >
> > > Phil.
> > > ________________________________________________________
> > > Philippe TROTIN
> > > Microsoft Services France http://www.microsoft.com/france
> > >
> > > "Yan" wrote in message
> > > news:41c98d40$0$12848$
> > > > Bonjour,
> > > >
> > > > Je souhaite créer une vue si elle n'existe pas déjà, ou la
> > sinon.
> > > >
> > > > J'ai pensé à faire comme ça par exemple :
> > > >
> > > > if exists (select * from dbo.sysobjects where id > > > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') > 1)
> > > > ALTER VIEW ViewTOTO AS SELECT ...
> > > > else
> > > > CREATE VIEW ViewTOTO AS SELECT ...
> > > >
> > > > Mais apparamment, seul DROP est autorisé après le test if, sauf
> les
> > > > tables.
> > > >
> > > > Alors y a-t-il un autre moyen de faire ?
> > > >
> > > > Merci d'avance
> > > >
> > > > Yan
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Bonjour,
Pas de quoi.
Joyeux Noel.
Phil.
________________________________________________________
Philippe TROTIN http://blogs.msdn.com/ptrotin
Microsoft Services France http://www.microsoft.com/france
"Yan" wrote in message
news:41caf715$0$7929$
> Ca c'est une bonne idée !
> J'ai essayé, ça marche bien
>
> Merci
>
>
>
>
> "Philippe T [MS]" a écrit dans le message
de
> news:
> > Bonjour,
> >
> > Alors, créer une chaine de caractère @SQL = N'ALTER VIEW ViewTOTO AS
> SELECT
> > ...'
> >
> > et utiliserun EXEC sp_executesql @SQL...
> >
> > Phil.
> > ________________________________________________________
> > Philippe TROTIN http://blogs.msdn.com/ptrotin
> > Microsoft Services France http://www.microsoft.com/france
> >
> > "Yan" wrote in message
> > news:41cac9fe$0$30803$
> > > Nan nan, ALTER ou CREATE VIEW ne sont pas possible après les test IF
> > >
> > >
> > >
> > >
> > > "Philippe T [MS]" a écrit dans le
message
> > de
> > > news:
> > > > Bonjour,
> > > >
> > > > if exists (select * from dbo.sysobjects where id > > > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') > 1)
> > > > BEGIN
> > > > ALTER VIEW ViewTOTO AS SELECT ...
> > > > END
> > > > else
> > > > BEGIN
> > > > CREATE VIEW ViewTOTO AS SELECT ...
> > > > END
> > > >
> > > > Phil.
> > > > ________________________________________________________
> > > > Philippe TROTIN
http://blogs.msdn.com/ptrotin
> > > > Microsoft Services France
> > > >
> > > > "Yan" wrote in message
> > > > news:41c98d40$0$12848$
> > > > > Bonjour,
> > > > >
> > > > > Je souhaite créer une vue si elle n'existe pas déjà, ou la
modifier
> > > sinon.
> > > > >
> > > > > J'ai pensé à faire comme ça par exemple :
> > > > >
> > > > > if exists (select * from dbo.sysobjects where id > > > > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView')
> > > > > ALTER VIEW ViewTOTO AS SELECT ...
> > > > > else
> > > > > CREATE VIEW ViewTOTO AS SELECT ...
> > > > >
> > > > > Mais apparamment, seul DROP est autorisé après le test if, sauf
pour
> > les
> > > > > tables.
> > > > >
> > > > > Alors y a-t-il un autre moyen de faire ?
> > > > >
> > > > > Merci d'avance
> > > > >
> > > > > Yan
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Bonjour,
Pas de quoi.
Joyeux Noel.
Phil.
________________________________________________________
Philippe TROTIN http://blogs.msdn.com/ptrotin
Microsoft Services France http://www.microsoft.com/france
"Yan" <yan@nepasrepondre.com> wrote in message
news:41caf715$0$7929$8fcfb975@news.wanadoo.fr...
> Ca c'est une bonne idée !
> J'ai essayé, ça marche bien
>
> Merci
>
>
>
>
> "Philippe T [MS]" <ptrotin@online.microsoft.com> a écrit dans le message
de
> news:OR6ZZoP6EHA.4008@TK2MSFTNGP15.phx.gbl...
> > Bonjour,
> >
> > Alors, créer une chaine de caractère @SQL = N'ALTER VIEW ViewTOTO AS
> SELECT
> > ...'
> >
> > et utiliserun EXEC sp_executesql @SQL...
> >
> > Phil.
> > ________________________________________________________
> > Philippe TROTIN http://blogs.msdn.com/ptrotin
> > Microsoft Services France http://www.microsoft.com/france
> >
> > "Yan" <yan@nepasrepondre.com> wrote in message
> > news:41cac9fe$0$30803$8fcfb975@news.wanadoo.fr...
> > > Nan nan, ALTER ou CREATE VIEW ne sont pas possible après les test IF
> > >
> > >
> > >
> > >
> > > "Philippe T [MS]" <ptrotin@online.microsoft.com> a écrit dans le
message
> > de
> > > news:OeqAvqE6EHA.3076@TK2MSFTNGP15.phx.gbl...
> > > > Bonjour,
> > > >
> > > > if exists (select * from dbo.sysobjects where id > > > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') > 1)
> > > > BEGIN
> > > > ALTER VIEW ViewTOTO AS SELECT ...
> > > > END
> > > > else
> > > > BEGIN
> > > > CREATE VIEW ViewTOTO AS SELECT ...
> > > > END
> > > >
> > > > Phil.
> > > > ________________________________________________________
> > > > Philippe TROTIN
http://blogs.msdn.com/ptrotin
> > > > Microsoft Services France
> > > >
> > > > "Yan" <yan@nepasrepondre.com> wrote in message
> > > > news:41c98d40$0$12848$8fcfb975@news.wanadoo.fr...
> > > > > Bonjour,
> > > > >
> > > > > Je souhaite créer une vue si elle n'existe pas déjà, ou la
modifier
> > > sinon.
> > > > >
> > > > > J'ai pensé à faire comme ça par exemple :
> > > > >
> > > > > if exists (select * from dbo.sysobjects where id > > > > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView')
> > > > > ALTER VIEW ViewTOTO AS SELECT ...
> > > > > else
> > > > > CREATE VIEW ViewTOTO AS SELECT ...
> > > > >
> > > > > Mais apparamment, seul DROP est autorisé après le test if, sauf
pour
> > les
> > > > > tables.
> > > > >
> > > > > Alors y a-t-il un autre moyen de faire ?
> > > > >
> > > > > Merci d'avance
> > > > >
> > > > > Yan
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Bonjour,
Pas de quoi.
Joyeux Noel.
Phil.
________________________________________________________
Philippe TROTIN http://blogs.msdn.com/ptrotin
Microsoft Services France http://www.microsoft.com/france
"Yan" wrote in message
news:41caf715$0$7929$
> Ca c'est une bonne idée !
> J'ai essayé, ça marche bien
>
> Merci
>
>
>
>
> "Philippe T [MS]" a écrit dans le message
de
> news:
> > Bonjour,
> >
> > Alors, créer une chaine de caractère @SQL = N'ALTER VIEW ViewTOTO AS
> SELECT
> > ...'
> >
> > et utiliserun EXEC sp_executesql @SQL...
> >
> > Phil.
> > ________________________________________________________
> > Philippe TROTIN http://blogs.msdn.com/ptrotin
> > Microsoft Services France http://www.microsoft.com/france
> >
> > "Yan" wrote in message
> > news:41cac9fe$0$30803$
> > > Nan nan, ALTER ou CREATE VIEW ne sont pas possible après les test IF
> > >
> > >
> > >
> > >
> > > "Philippe T [MS]" a écrit dans le
message
> > de
> > > news:
> > > > Bonjour,
> > > >
> > > > if exists (select * from dbo.sysobjects where id > > > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView') > 1)
> > > > BEGIN
> > > > ALTER VIEW ViewTOTO AS SELECT ...
> > > > END
> > > > else
> > > > BEGIN
> > > > CREATE VIEW ViewTOTO AS SELECT ...
> > > > END
> > > >
> > > > Phil.
> > > > ________________________________________________________
> > > > Philippe TROTIN
http://blogs.msdn.com/ptrotin
> > > > Microsoft Services France
> > > >
> > > > "Yan" wrote in message
> > > > news:41c98d40$0$12848$
> > > > > Bonjour,
> > > > >
> > > > > Je souhaite créer une vue si elle n'existe pas déjà, ou la
modifier
> > > sinon.
> > > > >
> > > > > J'ai pensé à faire comme ça par exemple :
> > > > >
> > > > > if exists (select * from dbo.sysobjects where id > > > > > > object_id(N'[dbo].[ViewTOTO]') and OBJECTPROPERTY(id, N'IsView')
> > > > > ALTER VIEW ViewTOTO AS SELECT ...
> > > > > else
> > > > > CREATE VIEW ViewTOTO AS SELECT ...
> > > > >
> > > > > Mais apparamment, seul DROP est autorisé après le test if, sauf
pour
> > les
> > > > > tables.
> > > > >
> > > > > Alors y a-t-il un autre moyen de faire ?
> > > > >
> > > > > Merci d'avance
> > > > >
> > > > > Yan
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>