Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2008 > SQL Server 2008
SQL Server 2008 General discussion of SQL Server *2008* version only - not related to a specific book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2008 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 5th, 2014, 05:57 PM
Friend of Wrox
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default Drop and create View behavior

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):

    strsql = " USE [DBName]" & _
         " GO " & _
         " IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[tblName]')) " & _
         " DROP VIEW [dbo].[viewName] " & _
         " GO "

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:

 USE [DBNAme] 
  IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].    [viewName]'))  
  DROP VIEW [dbo].[viewName]  
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
Wind is your friend
Old February 6th, 2014, 10:08 PM
Friend of Wrox
Join Date: Feb 2014
Posts: 136
Thanks: 1
Thanked 10 Times in 10 Posts

The most obvious is that the statements are different. In your top statement you where clause is a such
 WHERE object_id = OBJECT_ID(N'[dbo].[tblName]'))
and in bottom it is as such
 WHERE object_id = OBJECT_ID(N'[dbo].    [viewName]'))

Last edited by mmorgan30; February 6th, 2014 at 10:12 PM..

Similar Threads
Thread Thread Starter Forum Replies Last Post
drag-and-drop from toolbox to Markup View Rex777 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 5 September 22nd, 2008 01:54 PM
Help Grid View Drop Down List, view all jskinner123 ASP.NET 2.0 Basics 0 November 25th, 2007 06:25 PM
tree view drag drop.. c# chandler7272 C# 1 August 30th, 2006 09:23 AM
having some fields of a grid view a drop list dsblack@montgomerycountyt ASP.NET 2.0 Professional 0 June 2nd, 2006 04:18 PM
How to create a button drag and drop?? DefoxLion General .NET 0 March 2nd, 2005 02:44 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.