Wrox Programmer Forums
|
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 October 16th, 2003, 08:36 AM
Registered User
 
Join Date: Oct 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with some code

Hi Everyone, I am having some problems with this piece of code. Can anyone help please?

DECLARE @Command varchar(8000)
Declare @ISBNRoot varchar(7), @ISBNRootlength int

DECLARE Curs INSENSITIVE CURSOR FOR
    select ISBNRoot, datalength(Ltrim(Rtrim(ISBNRoot))) from ExporttblISBN order by 2
    FOR READ ONLY
    OPEN Curs
    FETCH NEXT FROM curs INTO @ISBNRoot, @ISBNRootlength
    WHILE (@@fetch_status <> -1) and @@fetch_status <> -2 BEGIN
        select @Command = "Update #tempT1 set ISBN = Left(ISBN, 1) + '-' + "
        --select @Command = "Select ISBN, Left(ISBN, 1) + '-' + "
        select @Command = @Command + " substring(ISBN, 2, " + convert(varchar(10), @ISBNRootlength - 2) + ") + '-' + "
        select @Command = @Command + " substring(ISBN, " + convert(varchar(10), @ISBNRootlength) + ", " + convert(varchar(10), 10 - @ISBNRootlength) + ") + '-' + "
        select @Command = @Command + " + Right(ISBN, 1) "
        select @Command = @Command + " From #tempT1 "
        select @Command = @Command + " where substring(ISBN,1 , " + convert(varchar(10), @ISBNRootlength - 1) + ") = '" + replace( @ISBNRoot , '-', '') + "'"
        select @Command
        execute (@Command)
        FETCH NEXT FROM curs INTO @ISBNRoot, @ISBNRootlength
    END
CLOSE Curs
DEALLOCATE Curs

All I get when I run it is:::::
Server: Msg 207, Level 16, State 3, Line 10
Invalid column name 'Update #tempT1 set ISBN = Left(ISBN, 1) + '-' + '.
Server: Msg 207, Level 16, State 1, Line 12
Invalid column name ' substring(ISBN, 2, '.
Server: Msg 207, Level 16, State 1, Line 12
Invalid column name ') + '-' + '.
Server: Msg 207, Level 16, State 1, Line 13
Invalid column name ' substring(ISBN, '.
Server: Msg 207, Level 16, State 1, Line 13
Invalid column name ', '.
Server: Msg 207, Level 16, State 1, Line 13
Invalid column name ') + '-' + '.
Server: Msg 207, Level 16, State 1, Line 14
Invalid column name ' + Right(ISBN, 1) '.
Server: Msg 207, Level 16, State 1, Line 15
Invalid column name ' From #tempT1 '.
Server: Msg 207, Level 16, State 1, Line 16
Invalid column name ' where substring(ISBN,1 , '.
Server: Msg 207, Level 16, State 1, Line 16
Invalid column name ') = ''.
Server: Msg 207, Level 16, State 1, Line 16
Invalid column name '''.

HELP:(
 
Old October 16th, 2003, 02:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

How did you define the temporary table #TempT1?

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent:hard disk serial code and vb code ivanlaw Pro VB 6 0 July 25th, 2007 04:05 AM
VB: .Exe file, serial code and activation code ivanlaw Pro VB 6 8 July 6th, 2007 05:44 AM
code clinic - Why wont example asp code work? jardbf Classic ASP Basics 3 April 27th, 2006 06:22 PM
Writing Client Side Script from Code-Behind code sajid_pk Classic ASP Databases 1 January 18th, 2005 12:53 AM
disable forum code within [code] blocks? nikolai Forum and Wrox.com Feedback 0 October 23rd, 2003 07:52 PM





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