I'm running SQL Server 2005 on prod, but developing on 2008, and I need to alter a view to add a column. However I'm having trouble creating the开发者_开发问答 deploy script because I need to wrap it in a transaction like this
begin tran;
alter view [dbo].[v_ViewName] with schemabinding
as
select ...
/* do other stuff */
commit;
When I do this the SQL IDE underlines the alter statement with an error saying that the 'ALTER VIEW' statement must be the only statement in a batch. ANd if I ignore this and just try and run it anyway it gives this error:
Incorrect syntax near the keyword 'view'.
Any ideas how to get around this?
A transaction can span multiple batches:
begin tran;
GO
alter view [dbo].[v_ViewName]
with schemabinding
as
select ...
GO
/* do other stuff */
GO
commit;
GO
精彩评论