Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2008 > SQL Server 2008
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 5th, 2014, 04:57 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
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):

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
__________________
Wind is your friend
Matt
Reply With Quote
  #2 (permalink)  
Old February 6th, 2014, 09:08 PM
Friend of Wrox
Points: 528, Level: 8
Points: 528, Level: 8 Points: 528, Level: 8 Points: 528, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2014
Posts: 136
Thanks: 1
Thanked 10 Times in 10 Posts
Default

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

Last edited by mmorgan30; February 6th, 2014 at 09:12 PM.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 05: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 01:44 AM



All times are GMT -4. The time now is 02:26 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.