Stored Procedure column Name problem


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Stored Procedure column Name problem

  1. #1
    david Guest

    Stored Procedure column Name problem


    I have a table with numbers for columns like so :
    columns ---> category title [1] [2] [3]
    asp code .5 .3 .7

    i am pulling data from another table and using that data as a lookup on this
    table. for instance.

    Select table1.number

    select [table1.number]/* <--this is where I have the problem, can anyone


    help! * for instance if the "table1.number" was 3 then it would pull back
    .7*/


    from table2




    From table1

  2. #2
    Colin McGuigan Guest

    Re: Stored Procedure column Name problem

    david wrote:
    > select [table1.number]/* <--this is where I have the problem, can
    > anyone


    SELECT table1.[7] FROM table1

    --
    Colin McGuigan




  3. #3
    Q*bert Guest

    Re: Stored Procedure column Name problem


    You need to build your SQL as a string and then use the EXEC SQL to run the
    sql.

    If I understand your question right, your tring to take the results of a
    query and pass them as the field names to another query, the only way this
    will work is if you use the EXEC SQL where SQL is the string concat of the
    SQL you want to execute.

    Eg.

    Declare @SQL varchar 1000

    SET @SQL = 'SELECT ' & Select Table1.number where table1.Limits=1 & ' FROM
    table2

    EXEC @SQL

    Hope this helps,

    Q*bert


    "david" <d_canova@hotmail.com> wrote:
    >
    >I have a table with numbers for columns like so :
    >columns ---> category title [1] [2] [3]
    > asp code .5 .3 .7
    >
    >i am pulling data from another table and using that data as a lookup on

    this
    >table. for instance.
    >
    >Select table1.number
    >
    >select [table1.number]/* <--this is where I have the problem, can anyone
    >
    >
    >help! * for instance if the "table1.number" was 3 then it would pull back
    >.7*/
    >
    >
    >from table2
    >
    >
    >
    >
    >From table1



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center