Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 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 April 2nd, 2008, 10:54 PM
Registered User
Join Date: Mar 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

Really? Maybe it's just that different versions have different syntaxes. Anyone out there who can explain this issue (the difference between 'GO' and ';')?

Adalberto Pineda
Old June 11th, 2013, 04:59 PM
Registered User
Join Date: Jun 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default This works

You can't use the GO command in a stored procedure.
This piece of code works for all versions of SQL. The key is to use the EXEC command.

   --SELECT *
   --FROM @ReportSet

   -- copy table variable @ReportSet into temp table #ESSReportSet because table variables cannot be altered.
   SELECT * INTO #ESSReportSet FROM @ReportSet

   -- Run the ALTER command outside of this batch, otherwise SQL will give "invalid column name" error on field det_UF_Revision
     ADD det_UF_Revision    NVARCHAR(8)')

   -- populate new det_UF_Revision field with jobmatl.uf_revision
     UPDATE #ESSReportSet
     SET #ESSReportSet.det_UF_Revision = jobmatl.uf_revision
     FROM #ESSReportSet ers
     -- Need to parse hdr_job using SUBSTRING and PATINDEX to get job and suffix fields
     LEFT OUTER JOIN jobmatl ON jobmatl.job = SUBSTRING(ers.hdr_job,1,PATINDEX('%-%',ers.hdr_job)-1)
          AND jobmatl.suffix = SUBSTRING(ers.hdr_job,PATINDEX('%-%',ers.hdr_job)+1,LEN(hdr_job)-PATINDEX('%-%',ers.hdr_job))
          AND jobmatl.oper_num = ers.sub_JobMatlOperNum
          AND jobmatl.sequence = ers.det_jobsequence

   -- select all of the fields in the new temp table
   FROM #ESSReportSet

Similar Threads
Thread Thread Starter Forum Replies Last Post
What do I need to add/alter? obrienkev C# 2005 1 November 1st, 2007 12:04 PM
Alter Column SQLScott SQL Server 2005 5 January 5th, 2007 11:53 AM
Alter Column - Default Value sasidhar79 SQL Server 2000 2 January 18th, 2005 07:30 AM
Alter Default on a Column Gert SQL Server 2000 4 November 28th, 2003 08:58 AM
Alter Table - Add Column liz@trinityholdings.co.za Access 2 July 29th, 2003 03:06 AM

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