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 2005 Forums
 Transact-SQL (2005)
 HOW to access tables by numbers?

Author  Topic 

NadAf
Starting Member

2 Posts

Posted - 2008-07-15 : 21:50:20
Hi,
Is it possible to access tables by numbers in SQL Server 2005?

Like this, for example:
SELECT * FROM tables(1) or objects(1) or whatever


where the number is like the index of an array, not the object identifier.

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-07-15 : 21:52:10
Didn't get it.
Go to Top of Page

NadAf
Starting Member

2 Posts

Posted - 2008-07-15 : 22:05:42
quote:
Originally posted by sodeep

Didn't get it.


For example, instead of:
SELECT * FROM My_Table

use
SELECT * FROM array(1)

Where array is an array of tables indexed by i.

My idea is to access a table without knowing its name
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-07-15 : 23:18:53
No, you can't.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-16 : 00:33:31
quote:
Originally posted by NadAf

quote:
Originally posted by sodeep

Didn't get it.


For example, instead of:
SELECT * FROM My_Table

use
SELECT * FROM array(1)

Where array is an array of tables indexed by i.

My idea is to access a table without knowing its name



You will have to pass your tablename as a parameter then and use dynamic sql to use the value. But this is not at all recommended.
Go to Top of Page
   

- Advertisement -