Hi there I am having some odd behavior with a view (sqlserver 2008 r2)
Here is the code in the file (ASP or VBS file same behavior):
Code:
strsql = " USE [DBName]" & _
" GO " & _
" IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[tblName]')) " & _
" DROP VIEW [dbo].[viewName] " & _
" GO "
conn.execute(strsql)
In my log file I get no error bu the script does not run. When I print the paste the strsql value to the log file and paste into SQL Management console and check query I get 'Incorrect syntax near 'GO' . Since the statement is one long string I reformat it like this and it works without issue:
Code:
USE [DBNAme]
GO
IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo]. [viewName]'))
DROP VIEW [dbo].[viewName]
GO
What am I missing here, I'm sure it obvious.... Can someone post an example of how they are running a create view in an ASP or VBS file? Note. All my CREATE Table, ALTER table etc statements are working fine. Its just the view im having trouble with
Thanking you