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