Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Irascible Syntax Errors

Author  Topic 

Xerxes
Aged Yak Warrior

666 Posts

Posted - 2005-02-14 : 15:47:36
I just can't see why this code

DECLARE @Tab_A table, TabID varchar(5), Tool varchar(13)
DECLARE @Tab_B table, TabID varchar(5), Tool varchar(13)
GO

INSERT INTO @Tab_A
SELECT 'Tab_A', 'Tire Iron ' UNION
SELECT 'Tab_A', 'Crowbar ' UNION
SELECT 'Tab_A', 'Monkey Wrench'

INSERT INTO @Tab_B (TabID, Tool)
SELECT 'Tab_B', 'Jackhammer ' UNION
SELECT 'Tab_B', 'Chainsaw ' UNION
SELECT 'Tab_B', 'Backhoe '
GO

INSERT INTO @Tab_A
SELECT TabID, Tool
FROM @Tab_B
GO

SELECT * FROM @Tab_A
SELECT * FROM @Tab_B


is giving me this:

Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near ','.
Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near ','.
Server: Msg 137, Level 15, State 2, Line 3
Must declare the variable '@Tab_A'.
Server: Msg 137, Level 15, State 1, Line 7
Must declare the variable '@Tab_B'.
Server: Msg 137, Level 15, State 2, Line 3
Must declare the variable '@Tab_A'.
Server: Msg 137, Level 15, State 1, Line 4
Must declare the variable '@Tab_B'.
Server: Msg 137, Level 15, State 2, Line 3
Must declare the variable '@Tab_A'.
Server: Msg 137, Level 15, State 1, Line 3
Must declare the variable '@Tab_B'.


I KNOW this has got to be something minor. I just don't see it.
Please point me in the right direction, my compass is broke



Semper fi, Xerxes, USMC(Ret.)
-------------------------------------------------------------------------
Once a Marine Programmer Analyst ALWAYS a Marine Programmer Analyst

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-02-14 : 15:50:17
Since your tables are variables you don't want the GO statments.

also:
DECLARE @Tab_A table (TabID varchar(5), Tool varchar(13) )
DECLARE @Tab_B table (TabID varchar(5), Tool varchar(13) )


Be One with the Optimizer
TG
Go to Top of Page

Xerxes
Aged Yak Warrior

666 Posts

Posted - 2005-02-14 : 15:56:20
This is what happens when I'm working with some complex code, then I need to run a Q&D on the SQA and it's ALWAYS something simple!

A salute to you, TG!

THANKS

Semper fi, Xerxes, USMC(Ret.)
-------------------------------------------------------------------------
Once a Marine Programmer Analyst ALWAYS a Marine Programmer Analyst
Go to Top of Page
   

- Advertisement -