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 2000 Forums
 SQL Server Development (2000)
 Problem with wild card comparison (char and varchar)

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-02-06 : 18:18:21
Manikandan writes "Hello,

There is a problem with sql server 2000 and also with sql server 7.0. The problem is described below :-

I will be glad if i u can let me know the solution for this.

Problem with char and varchar:

I've created a stored procedure in the pubs database. The stored proc is given below:

CREATE PROCEDURE test
@p1 char(20)
as
begin
select * from authors where au_lname like @p1
end
GO

But in the authors table, the definition of au_lname is varchar(20). The documentation says that char to varchar conversion is implicit.

But if i try to execute the procedure using

Execute test 'w%'

Even though there is a record present for the particular criteria, no rows are getting returned. There is some problem only while using the wild card character. If we use 'equal to' sign instead of 'like' in the sql, it works fine.

I can't change the declaration as there are lot of procedures and checking each and every parameter for the particular condition is not feasible.

Any help on this will be appreciated.

Cheers
Manikandan"
   

- Advertisement -