SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MS SQL: Triggers

    hello,
    could someone please tell me whats wrong with this code

    Its a trigger variable am trying to assign a value to. It says there is a error 170 with the '=' assignment function

    Basically, i am trying to assign a value of two variables to one.

    select convert(money, @credit_aft2) = ( convert(money,@amt) - convert(money,@purse))

    thanks
    Afrika

  2. #2
    SitePoint Addict markchivs's Avatar
    Join Date
    Oct 2004
    Location
    Malvern Hills, UK
    Posts
    233
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Never heard of a trigger variable

    But in your example you cannot do a convert on the variable while your assigning a value to it:

    Code:
    select convert(money, @credit_aft2) = ( convert(money,@amt) - convert(money,@purse))
    try this:

    Code:
    select @credit_aft2 = convert(money, (convert(money,@amt) - convert(money,@purse)))
    Mind you if your doing a convert on both values to the right of the = sign wont it give you a money datatype anyhow? So this should work:

    Code:
    select @credit_aft2 = convert(money, (@amt-@purse))
    In fact!!! If you've declared @credit_aft2 as a money datatype. Your query should do the conversion internally:

    Code:
     
    declare @credit_aft2 money
     
    select @credit_aft2 = @amt-@purse
    ha ha ha



  3. #3
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks a lot,
    i didnt know i could declare a variable as money. This code worked

    delcare @credit_aft2 money

    select @credit_aft2 = convert(money,@amt)- convert(money,@purse)


Bookmarks

Posting Permissions

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