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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.