SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2001
    Location
    London
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    stored procedure count data type

    Hi,

    attempting to retrieve the count of all topics in a table related to the main topic in the same table. Make sense?
    This would work ,but when I attempt to retrieve the count and pass it to a integer variable it fails. How do I convert it? I have failed in my attempts.

    Code:

    declare @topic_count int, @count nvarchar(5)
    set @topic_count = 0

    if (@topic_parent <> -1)

    begin

    select count(topic_id) as 'Count' from topics where topic_parent = @topic_parent

    set @count = 'Count'
    set @topic_count = convert(int, @count)

    update topics set topic_count = 9 where topic_id = 20 and topic_parent = -1

    end

    INSERT INTO topics(forum_id, u_id, topic_name, topic_parent, topic_count, topic_message) VALUES (@forum_id, @u_id, @topic_name, @topic_parent, @topic_count, @topic_message)


    Any ideas??
    cheers

  2. #2
    SitePoint Member
    Join Date
    Nov 2001
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Try This

    Try Assigning like this:
    select @count = count(topic_id) from topics where topic_parent = @topic_parent
    I'm not sure what the type is.

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2001
    Location
    London
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks so much worked a treat...



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
  •