Results 1 to 4 of 4

Thread: TBALE datatype

  1. #1
    Join Date
    Feb 2003
    Posts
    13

    Unanswered: TBALE datatype

    I'm trying to utilize the table datatype to display a single column from the declared table. I keep getting the error message listed below. If I want to display all of the columns it's no problem but I need to be able to join declared tables together to get a result set.

    ex.

    declare @orders table(
    orderid int,
    customerid varchar(10),
    employeeid int,
    orderdate datetime,
    requireddate datetime,
    shippeddate datetime,
    shipvia int,
    freight money)

    insert @orders select orderid,customerid,employeeid,orderdate,requiredda te,shippeddate,shipvia,freight from orders

    select @orders.orderid from @orders

    Server: Msg 170, Level 15, State 1, Line 12
    Line 12: Incorrect syntax near '.'.

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    select orderid from @orders
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Feb 2003
    Posts
    13

    TABLE datatype

    I believe I need to further clarify my situation. I'm trying to join to declared tables together and getting the following error (listed below).

    declare @orders table(
    orderid int,
    customerid varchar(10),
    employeeid int,
    orderdate datetime,
    requireddate datetime,
    shippeddate datetime,
    shipvia int,
    freight money)

    insert @orders select orderid,customerid,employeeid,orderdate,requiredda te,shippeddate,shipvia,freight from orders

    declare @emps table(
    employeeid int,
    lastname varchar(40),
    firstname varchar(20),
    title varchar(60))

    insert @emps select employeeid, lastname, firstname, title from employees


    select @orders.orderid, @emps.employeeid
    from @orders, @emps
    where @orders.employeeid = @emps.employeeid

    Server: Msg 170, Level 15, State 1, Line 22
    Line 22: Incorrect syntax near '.'.

  4. #4
    Join Date
    Oct 2003
    Location
    Newcastle, Australia
    Posts
    51
    Try using a table alias

    eg

    select o.orderid, e.employeeid
    from @orders o, @emps e
    where o.employeeid = e.employeeid

Posting Permissions

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