Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Posts
    1

    Unanswered: Inline variable assignment

    I have to write a query for printing multiple barcodes, depending on the quantity of items that came in the store, based on the order number.

    [code (simplified)]

    DECLARE @num INT
    SELECT BarCodes.BarCode, BarCodes.ArticleID, ArticlesTrafic.DocumentID, ArticlesTrafic.TrafficQuantity
    FROM BarCodes INNER JOIN
    Articles ON BarCodes.ArticleID = Articles.ArticleID INNER JOIN
    getAutoNumberTable(@num) ON @num=ArticlesTrafic.TrafficQuantity
    WHERE (ArticlesTrafic.DocumentID = @Param2)

    [/code]

    The thing i would like to do, is somehow assign a value to @num and pass it to the getAutoNumberTable stored procedure, which generates a table of consequtive numbers, so that each record is displayed multiple times. Is it even possible to do it without using temp tables and loops?
    Last edited by zadet; 01-22-04 at 16:14.

  2. #2
    Join Date
    Jan 2004
    Location
    Romania - Bucharest
    Posts
    50
    Try changing your getAutoNumberTable(@num) Stored Procedure in an Inline UDF, something like:

    Create function getAutoNumberTable(@num type)
    returns table
    as
    select ...

    Then, you could use getAutoNumberTable(@num) as a "regular" table

    See Books Online and the templates provided by the QA on "inline functions"

Posting Permissions

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