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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing Column in @TableVariables??????

Status
Not open for further replies.

rmahawaii

Programmer
Oct 21, 2002
29
HK
Hello All, I am having problem accessing a column from the table variable. Can anyone please show me how? Thanks in advance.

declare @TableVar1 table ([chrChangeType] [char] (1),
[chrBeforeIDType] [char] (2))

Insert Into @TableVar1 (chrChangeType, chrBeforeIDType)
Select chrChangeType, chrBeforeIDType
FROM tblcustidchanged

'This is where the error raise'
SELECT @TableVar.chrChangeType
FROM @TableVar1
 
On first glance, you are missing a '1':

[tt]SELECT @TableVar1.chrChangeType
FROM @TableVar1[/tt] --James
 
OH..it's a typo here but it still won't work when I typed

SELECT @TableVar1.chrChangeType
FROM @TableVar1

Thanks
 
I take it you are creating the variable and selecting from it within the same connection (ie running that script you posted "as is")?

If so, what is the error you are getting? --James
 
Server: Msg 170, Level 15, State 1, Line 27
Line 27: Incorrect syntax near '.'.

Thanks
 
Oh I got the answer...cannot use

Table.columnName

only Select columnName From table
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top