Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL Queries.

Author  Topic 

TazMania
Yak Posting Veteran

63 Posts

Posted - 2003-04-17 : 15:20:22
Hi

I'm quite new to the whole SQL Scripting environment,
But I have this question that I hope some of you can help me with.

I've made an little statssite, which are count the amount of posts an user has made to my forum in one month's time.
but I can't seem to get it to work that right way.

Here's what I've come up with so far.

Forum topics :
SELECT COUNT(forumID) AS AntalPosts FROM FORUM WHERE forumUSERNAME='"&Session("ID")&"' AND DATEDIFF(month, forumDATE, getdate() ) = 1

Forum answers :
SELECT COUNT(itemID) AS AntalSvar FROM Forum_Item WHERE itemusername='"&Session("ID")&"' AND DATEDIFF(month, itemDATE, getdate() ) = 1

Best regards
Taz

X002548
Not Just a Number

15586 Posts

Posted - 2003-04-17 : 16:36:48
I vote for creating a stored procedure and call that and pass in the parameteres...do you know how to execute a sproc from your code...if not search the forums, I know the answer has got to be out there.





Brett

8-)
Go to Top of Page

TazMania
Yak Posting Veteran

63 Posts

Posted - 2003-04-18 : 05:02:14
Hi again :)

Thx for the reply, I'll try to search the forums again,
sproc code what's that ? :)

Best regards
Taz
Go to Top of Page

samsekar
Constraint Violating Yak Guru

437 Posts

Posted - 2003-04-18 : 05:22:42
Hmm
spoc ==> Stored Procedure


Sekar
~~~~
Success is not a destination that you ever reach. Success is the quality of your journey.
Go to Top of Page

TazMania
Yak Posting Veteran

63 Posts

Posted - 2003-04-18 : 06:41:56
Thx :D lol weee learned a new word :P

but please correct me if i'm wrong, but creating sproc code wouldn't it be the same as executing my code either via asp or directly on the sql server..

I tried last night executing that query in query analyzer, and it didn't count correctly, as it did if i counted it by hand.

But it's worth a try and I'll then learn something new :)

Best Regards
Taz
Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2003-04-18 : 09:05:33
The result set will be the same.

A stored procedure will be compiled and an executed plan generated and stored in cache. For most queries this will result in a performance increase. It's beneficial to have one centralized reposatory for all your stored procedures. It makes your middle tier or client tier code cleaner and more compact. It allows you to give permissions to users or roles and assign permissions to each stored procedure. Allows for input and output parameters. Allows for multiple sql statements, transactions and interaction with activex objects, dts, bcp, other sp's and the list goes on...




Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-04-18 : 12:08:56
Wow, great adivce...but did you just blow his mind!



Brett

8-)
Go to Top of Page

TazMania
Yak Posting Veteran

63 Posts

Posted - 2003-04-19 : 06:49:11
Problem solved, not via sproc but apperently my datediff function was wrong hehe set it to vbusesystem instead and that worked.

Thx for all the replies

Best regards
Taz

Go to Top of Page
   

- Advertisement -