@Tbl = 'myDB.dbo.MyTable' -> Select * from @Tbl . Why doesn't this work ???

@Tbl = 'myDB.dbo.MyTable' -> Select * from @Tbl . Why doesn't this work ???

Post by Henrik Nordtor » Fri, 25 Aug 2000 04:00:00



Hi,

In my stored procedure I want to be able to refer to database and tabels
throught variables, not with their name directly.

Instead of  using;

    "Select * from myDB.dbo.myTable"

I want to use;



But I can't make it work. How can I make this work ???

-   Henrik Nordtorp
    Merkantildata

 
 
 

@Tbl = 'myDB.dbo.MyTable' -> Select * from @Tbl . Why doesn't this work ???

Post by Wayne Snyde » Fri, 25 Aug 2000 04:00:00


Use the exec command .... a la




> Hi,

> In my stored procedure I want to be able to refer to database and
tabels
> throught variables, not with their name directly.

> Instead of  using;

>     "Select * from myDB.dbo.myTable"

> I want to use;



> But I can't make it work. How can I make this work ???

> -   Henrik Nordtorp
>     Merkantildata

--
Wayne Snyder MCSE, MCDBA, MCT, SQL SERVER MVP
IKON Education Services, C*te, NC
(Please respond only to the newsgroups.)

Sent via Deja.com http://www.veryComputer.com/
Before you buy.

 
 
 

1. plpgsql: 'SELECT * FROM tbl'

If I do something like that, psql claims:

ERROR: unexpected SELECT query in exec_stmt_execsql()

why? How do I do this?

--
 Turbo     __ _     Debian GNU     Unix _IS_ user friendly - it's just
 ^^^^^    / /(_)_ __  _   ___  __  selective about who its friends are
         / / | | '_ \| | | \ \/ /   Debian Certified Linux Developer  

  \\\/  \____/_|_| |_|\__,_/_/\_\ Stockholm/Sweden

iodine NORAD Saddam Hussein Ft. Bragg colonel assassination Honduras
$400 million in gold bullion Nazi killed Rule Psix World Trade Center
radar plutonium explosion
[See http://www.aclu.org/echelonwatch/index.html for more about this]

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

2. Dynamic 4GL on Linux

3. SELECT permission denied on object 'mytable', database 'mydb', owner 'me'. to run query string from asp web page

4. Oracle 9.0.1 crashes every time a client connection is closed

5. Why doesn't this compile: Dim mydb as Database

6. sheduled DTS fails !

7. MSaccess tbl sees 'Deleted' instead of data from SqlSvr tbl

8. limit of 256 tables

9. copying tbl and it's constraints?

10. T-SQL to Join Tbl X with Tbl Y, update Tbl Y qty field with tbl.X count

11. ADO syntax prob - Insert Into SqlSvr7 tbl from Access mdb tbl

12. Add PkID (source tbl) into FkID (foriegn tbl)....

13. Why doesn't this SELECT statement return resuls