|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
|||
|
|||
|
Grab first X number of Records (SPROC)
Hi All,
I am totally new to MSSQL and stored procedures. I am trying to create a stored procedure that takes that is sent an int that represent a number of records to be returned.. not sure how to do this but this is what i've got: ALTER PROCEDURE GetNewUserJob @campaign_id int, @amount int AS /* SET NOCOUNT ON */ SELECT TOP @amount campaign_to_email.email_id, email_addresses.email_address FROM campaign_to_email INNER JOIN email_addresses ON campaign_to_email.email_id = email_addresses.email_id WHERE (campaign_to_email.campaign_id = @campaign_id) AND campaign_to_email.in_job IS NULL AND campaign_to_email.is_sent IS NULL RETURN Any help is appreciated! Thanks! |
|
#2
|
|||
|
|||
|
Code:
ALTER PROCEDURE GetNewUserJob @campaign_id int, @amount int AS /* SET NOCOUNT ON */ set rowcount @amount SELECT campaign_to_email.email_id, email_addresses.email_address FROM campaign_to_email INNER JOIN email_addresses ON campaign_to_email.email_id = email_addresses.email_id WHERE (campaign_to_email.campaign_id = @campaign_id) AND campaign_to_email.in_job IS NULL AND campaign_to_email.is_sent IS NULL RETURN |
|
#3
|
|||
|
|||
|
nice!
Thanks for the help!!
rw |
|
#4
|
|||
|
|||
|
You can also use the TOP keyword in the select statement:
SELECT TOP 2 * FROM dbo.Orders -- Messorian |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Grab first X number of Records (SPROC) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|