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 2005 Forums
 Transact-SQL (2005)
 Search the records

Author  Topic 

tomislavg
Yak Posting Veteran

51 Posts

Posted - 2009-12-19 : 08:00:09
Hi Gents, I have a qustion if you could help out.

I have the script below.

CREATE PROCEDURE [dbo].[spGetData]
@LastName nvarchar (50),
@FirstName nvarchar (50)
AS
SELECT SI.FirstName,
SI.FamilyName,
SI.DOB,
DI.Dep_Name
FROM Int_Staff SI
inner JOIN
IntlDep DI ON SI.StaffId = DI.StaffId
WHERE
SI.FamilyName like @LastName
OR
SI.FirstName like @FirstName




But when it is executed I want to only LastName or FirstName. I do not want to enter both to get the results.
Any idea?
Thanks a lot,
Tomislav

cat_jesus
Aged Yak Warrior

547 Posts

Posted - 2009-12-19 : 09:49:38



CREATE PROCEDURE [dbo].[spGetData]
@LastName nvarchar (50) = null,
@FirstName nvarchar (50) = null
AS
SELECT SI.FirstName,
SI.FamilyName,
SI.DOB,
DI.Dep_Name
FROM Int_Staff SI
inner JOIN
IntlDep DI ON SI.StaffId = DI.StaffId
WHERE
SI.FamilyName like @LastName
OR
SI.FirstName like @FirstName


An infinite universe is the ultimate cartesian product.
Go to Top of Page
   

- Advertisement -