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.
| Author |
Topic |
|
isdngirl
Starting Member
2 Posts |
Posted - 2004-08-19 : 20:47:30
|
| Youll have to forgive me a I am completly new to the world of SQL (been living access for years)Apparently I have been told at my job I need to start using store procedures, so I started playing around with them and created my first after reading some post on here:o CREATE PROCEDURE sp_numberOnlineCourses (@RowCount INT OUTPUT)ASSELECT resourceStatus,productNameFROM onlineCourseCatalog_qryWHERE resourceStatus='Available'ORDER BY resourceStatus,productNameSELECT @RowCount = @@RowCountGOSo my question is, can a SP do more than one thing at once (right now it just returns the count of the records)? If so how would I add this so it returns what it currently returns (the total about of records) and I also want it to return the amount of records grouped by product. SELECT Count(*)as c, productNameFROM dbo.onlineCourseCatalog_qryGROUP BY productNameORDER BY productName Not sure if that makes sense but basically I want it to do two things at once rather than writing 2 SPs.In addition, would anyone be able to recommend a good books/on SP - something preferably for a newbie?Thanks in advanceSara Ogsbury |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-08-19 : 20:59:24
|
| You really need to keep your recordset returns in seperate stored procedures so I would write two for this unless it's a report. If it's a report, just put in the second part before the GO. Some good books are:Teach Yourself Transact-SQL in 21 Days by Sams PublishingAnything by Ken Hendersonhttp://www.sqlteam.com/store.aspMeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
isdngirl
Starting Member
2 Posts |
Posted - 2004-08-20 : 10:31:10
|
| Thanks derrickleggett:It is for a report and I will defintly check out that book.CheersSara |
 |
|
|
|
|
|