Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax Problem between Servers

Status
Not open for further replies.

grnzbra

Programmer
Mar 12, 2002
1,273
US
I have the following code on two computers which are on different networks. On one (where I originally wrote it) it works fine. However, when it is moved to the production system, I get a syntax error on the word "FOR" in the cursor declaration. Both systems use Windows 10 Pro. The SQL Server Management Studio on which it was originally written is v17.8. I don't know what the other system's Management Studio version is. What might be the reason the production system chokes on this code? (Ignore the fact that this code would result in duplicate values in the fldWarrantyKey; another field is actually the key in this table.)

Code:
DECLARE @WarKey				UNIQUEIDENTIFIER
DECLARE @WarNum				VARCHAR(150)
DECLARE csrWarKey CURSOR [highlight #FCE94F]FOR[/highlight]
SELECT DISTINCT fldNumber
FROM dbo.tblWarranty
ORDER BY fldNumber

OPEN csrWarKey
FETCH NEXT FROM csrWarKey INTO[highlight #FCE94F][/highlight]
    @WarNum

WHILE @@FETCH_STATUS = 0
BEGIN
    SET @WarKey = NEWID()
    UPDATE dbo.tblWarranty
    SET fldWarrantyKey = @WarKey
    WHERE fldNumber = @WarNum
    FETCH NEXT FROM csrWarKey INTO
        @WarNum
END

CLOSE csrWarKey
DEALLOCATE csrWarKey
 
What is the version of SQL Server?
The version of SSMS do not matter :)

Borislav Borissov
VFP9 SP2, SQL Server
 
Don't know what happened. I retyped the cursor declaration and the problem went away. When I compared the two, they looked exactly alike. Perhaps the bad statement had an unprintable character or something in there somewhere.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top