Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language 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 September 26th, 2006, 10:54 PM
Registered User
Join Date: Mar 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to phishcoder
Default Using variable for table name

Executing the included query gives the following error:
"Msg 137, Level 15, State 2, Line 9
Must declare the variable '@imailTable'."

Replacing the @imailTable with dbo.ilivewell_net executes without error.

Thanks in advance for your help.


declare @imailTable varchar(30)
declare @userid        varchar(30)
declare @PW2        varchar(31)

set @imailTable = 'dbo.ilivewell_net'
set @userid = 'deleteme'

select @PW2 = password 
from @imailTable
where userid = @userid

Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacing a table name with a server variable topshed Classic ASP Basics 3 October 4th, 2007 11:52 PM
table variable query hai SQL Server DTS 5 June 11th, 2007 05:19 AM
Populate a Variable From Access Table sirmilt Access 5 March 21st, 2006 01:34 AM
Number of table rows to a variable Paula222 Access VBA 2 February 7th, 2006 09:33 AM
insert value of variable into an existing table mountaindew7612 SQL Server 2000 5 October 16th, 2004 12:48 PM

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