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 |
|
mellamokb
Starting Member
39 Posts |
Posted - 2005-12-30 : 10:41:59
|
| Hi, I need to write a procedure that retrieves a list of contacts from a contact table, in which the contact types are stored by id; I only want the contacts that are a certain contact type [prospector], but I want to use the contact type name, not ID to compare because that should never change, while the ID could change. Another table contains the contact types with ID's to link them to the contact table. Here is the code I use, but when I retrieve the information from the procedure using a page online, the page stops loading after the procedure is executed:--------------------- CODE -------------------CREATE Procedure getProspectorsASSELECT [contact table].ID, [contact table].contactFROM [contact table]INNER JOIN [contact types table] ON [contact table].contactType = [contact types table].IDWHERE [contact types table].contactType = 'prospector'ORDER BY contact ASCRETURNGO---------------------- END CODE ----------------I don't really know that much about SQL - I copied the idea from some other procedures. Is there a reason why this wouldn't work?thanks,melloamokb |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2005-12-30 : 12:35:33
|
| Try the following :1. Run the SQL Query alone, in Query Analyzer and c whether it gives any result2. Run the stored procedure in Query Analyzer and c whether it gives any result3. Remove the Return & check the result4. Write a simple Query (Select * from contacts) & check the result5. Put Begin & End in the begining & in the end respectively, in the Procedure. Another idea : U can have this query written in a View & get the desired result. |
 |
|
|
|
|
|