MSSQL LIKE and IN statements in ADO problem

Peter A. Schott paschott at
Wed Jan 18 17:46:59 EST 2006

Well, the raw TSQL would be:

select * from tb_name where firstname like '%raj%'

I think that would more translate to:

name = "raj"
cmd.CommandText = "SELECT * FROM tb_name WHERE firstname like '%%%s%%'" % name

Perhaps issuing a print statement of the CommandText would help for future runs
to determine if this is valid TSQL syntax?


"gregarican" <greg.kujawa at> wrote:

> Can't you get rid of the Create Parameter part and directly pass along
> the value you are looking for? Something like...
> name = 'raj'
> cmd.CommandText= \
>         "SELECT * FROM tb_name WHERE firstname LIKE %%%s" % name
> This way the value of the name variable gets passed along when the
> CommandText method is invoked. BTW, this looks too painfully much like
> Visual Basic than Python :-) Just kidding (kind of)

More information about the Python-list mailing list