Results 1 to 4 of 4

Thread: Join in SQL

  1. #1
    Join Date
    Sep 2010
    Posts
    19

    Question Unanswered: Join in SQL

    All,
    i know that we can use JOIN with Tables in SQL
    but my question is , can we use JOIN with declared tables inside stored
    procedure like this
    declare @MyTable table (
    [Code] int )
    insert into @MyTable
    select * from Table2

    select [Code2] from CodesTable Inner Join @MyTable On [Code] = CodesTable.[Code2]
    Can This Be DONE ?????

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by memo2010 View Post
    select [Code2] from CodesTable Inner Join @MyTable On [Code] = CodesTable.[Code2] Can This Be DONE ?????
    Yes. It probably would have taken less time to stick your code into SQL Server and try it than ask us!

    The only caveat is that the compiler assumes about 20 rows in your table variable, irrespective of how many you put in there. So do not use one if you plan to insert 200k rows.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Sep 2010
    Posts
    19
    ya man it's work , with little change in syntax , like this

    SELECT CodsTable.[Code2],b.[Code]AS [AgtCode]
    FROM CodsTable INNER JOIN
    @Mytable As b ON CodsTable.[Code2] =b.[Code]

  4. #4
    Join Date
    Sep 2010
    Posts
    3
    yes, u can insert the JOIN command in the SQL query.The format u have given is correct.

Tags for this Thread

Posting Permissions

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