Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2003
    Posts
    7

    Unanswered: SQL Server 2000 -> T-SQL -> Table data type

    Does any one have any examples of how to declare and use these properly?

    MSDN doesn't seem to give any example for a beginner.

  2. #2
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    Did you refer to the Books online (The Holy Book). Look under the topic table variables
    Get yourself a copy of the The Holy Book

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

  3. #3
    Join Date
    Jan 2003
    Location
    India
    Posts
    523

    Re: SQL Server 2000 -> T-SQL -> Table data type

    declare @table table(colname varchar(32))

    insert into @table (colname)
    values ('data')

    select * from @table


    It can be used just like any other table and
    table variables are cleaned up automatically at the end of the function, stored procedure, or batch in which they are defined.

  4. #4
    Join Date
    Apr 2003
    Posts
    7
    Declare @tblDetailData TABLE(DetailsData_FundID int, DetailsData_FundCountryID varchar(3), DetailsData_FieldID int, DetailsData_Data varchar(512))

    INSERT @tblDetailData SELECT 4008765, 'OX', DetailsData_FieldID, DetailsData_Data FROM DetailsData WHERE DetailsData_FieldID in (311, 75, 5, 6, 835, 836, 837, 838, 839, 829, 828) AND DetailsData_FundID = 4008765 AND DetailsData_FundCountryID = 'OX'

    INSERT INTO DetailsData(DetailsData_FundID, DetailsData_FundCountryID, DetailsData_FieldID, DetailsData_Data) Select * from @tblDetailData

    INSERT INTO TransDetailsData(DetailsData_FundID, DetailsData_FundCountryID, DetailsData_FieldID, DetailsData_Data) Select * from @tblDetailData

    will this work? i mean how would i use the table in an insert statement into another table? like above?


    ps. Enigma your link isn't working at the moment
    Last edited by thomaskeegan; 02-09-04 at 09:39.

Posting Permissions

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