I have a stored procedure :
<code
Create Procedure ControlDept
(
@.DeptID nvarchar(10)
)
As
If Exists
(
Select DeptName From Departments Where
DeptID LIKE @.DeptID
)
Return 1
Else
Return 0
Now I want to apply replace and upper functions to DeptID in database before saying
"DeptID LIKE @.DeptID".
for example the parameter is :"D&V"
DeptID in database is:"d & v" //there are spaces
if I say DeptID LIKE @.DeptID nothing is found because of character nonmatching
So I have to apply replace & upper functions to the column DeptID in database
but how?
can you help me please??You probably don't need the "Upper" function since *most* SQL Server functions are case insensitive by default.
As for the spaces, not sure what to tell you there. That's a one-off solution that you will have to code manually. For instance, what happens when the value is "D& V"? There are 2 spaces now, and you'd have to code a check for that too.
Also, if you are using LIKE, you need to have a % character. For example:
DeptID LIKE @.DeptID + '%'
No comments:
Post a Comment