Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003

    Exclamation Unanswered: help in visual basic

    This statement doesnt give back any result in Visual Basic on SQL
    QUERY ANALYZER it returns "select * from @tab" how to make this a stored procedure

    declare @tab table (idur int, data_val smalldatetime, [description] char(200), debi numeric(16,2), kredi numeric(8,2), cum numeric(8,2))
    insert into @tab select idur,data_val,description,debi,kredi,0 as cum from transaksionet where partia = '0001' order by data_val,idur,brloc
    declare @cum numeric(16,2)
    set @cum = 0
    update @tab
    set @cum = cum = @cum + kredi - debi
    select * from @tab

  2. #2
    Join Date
    Jun 2003
    Provided Answers: 1
    Some problems with your code:

    Don't use an ORDER BY clause when inserting data into your table variable. Since your table has no clustered index, you have to use the ORDER BY statement when retrieving data from the table in order to guarantee the order of the result set.

    Later, you use an UPDATE statement against your @TAB table, but the only value you modify is @CUM, which isn't even in your @TAB table. Is this a typo? Did you mean to update the CUM field in your @TAB table? Otherwise, you don't need the UPDATE statement, as you can just set the value of @CUM directly.

    Lastly, what's up with thie:

    set @cum = cum = @cum + kredi - debi

    Doubling up the assignement operators is not allowed within SQL.

    Clean these things up and then see if you still are experiencing problems.


  3. #3
    Join Date
    Jul 2003


    thats because I need to calculate running totals

    i fixed my problem

Posting Permissions

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