Friday, March 9, 2012

how to read the query in store procedure

i wrote a stored procedure here is the code

CREATE Procedure dm_deleteBBPost
(
@.TopicIDnumeric,
@.ForumIDnumeric

)
As
declare @.netCount as int

BEGIN
Select @.netCount=count(*) from tablename where TopicID=@.TopicID

update tablename set TotalTopics=TotalTopics-1,TotalPosts=TotalPosts-@.netCount where ForumID=@.ForumID

Delete From tblBBPosts Where TopicID = @.TopicID
Delete From tblBBTopics Where TopicID =@.TopicID

end
declare @.pr_ForumsToday as varchar

////////// select Top 1 * from tablename order by column name desc
GO

IN that last line one row will be displayed. how can i read one of the field from the query (selct top1 etc)

Quote:

Originally Posted by madhu7sudan

i wrote a stored procedure here is the code

CREATE Procedure dm_deleteBBPost
(
@.TopicIDnumeric,
@.ForumIDnumeric

)
As
declare @.netCount as int

BEGIN
Select @.netCount=count(*) from tablename where TopicID=@.TopicID

update tablename set TotalTopics=TotalTopics-1,TotalPosts=TotalPosts-@.netCount where ForumID=@.ForumID

Delete From tblBBPosts Where TopicID = @.TopicID
Delete From tblBBTopics Where TopicID =@.TopicID

end
declare @.pr_ForumsToday as varchar

////////// select Top 1 * from tablename order by column name desc
GO

IN that last line one row will be displayed. how can i read one of the field from the query (selct top1 etc)


Try this...

SELECT TOP 1 COLUMNNAME FROM TABLENAME ORDER BY COLUMN NAME DESC

No comments:

Post a Comment