Dynamic FROM clause

Results 1 to 2 of 2

Thread: Dynamic FROM clause

  1. #1
    Join Date
    Dec 1969

    Default Dynamic FROM clause

    I was wondering if it were possible to use a string containing a tablename in a select statement like this:<BR><BR>declare @test sysname<BR>set @test = &#039;tablename&#039;<BR>select * from @test<BR><BR>Basically creating a dynamic from clause. Thanks in advance.<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Dynamic FROM clause

    You can save the Table Name as a string but there isnt a tablename type.<BR>Try <BR>Dim stTablename as string<BR>stTableName = "tblTableName"<BR>"Select " & stTablename & ".* From " & stTableName & ";"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts