Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi All.I have view with Patients name and Appointment table where I save those patients. How to create store procedure if I would like to select one patient record based on Patient_Id value?Thanks.
James K
Master Smack Fu Yak Hacker
3873 Posts
Posted - 2013-09-18 : 11:15:57
Like this. The red portions if you have multiple rows for a patient and you want to select only one row
create procedure dbo.GetOnePatient @Patient_ID intasset nocount on;select TOP (1) col1,col2,col3,...from Appointmentwhere patient_id = @Patient_IDOrder by somecolumn