Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old April 2nd, 2008, 10:54 PM
Registered User
Join Date: Mar 2008
Location: CA, USA.
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
Reply With Quote
  #12 (permalink)  
Old June 11th, 2013, 04:59 PM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
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
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
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

All times are GMT -4. The time now is 03:35 AM.

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