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)
 Like Operator

Author  Topic 

haroon2k9
Constraint Violating Yak Guru

328 Posts

Posted - 2010-11-02 : 02:05:12
hi ,

tbl name :Detailstbl

column - id(int),hdcasename :varchar(255)
id hdcasename

1 test

2 tree

3 school


just do the search by id or hdcasename is the parameter..


example searchparam : hd-001 (input param)
result :
id hdcasename
1 tes

input can be : test

result

id hdcasename
1 test


this is all abt the req(inbput param can be id prefixed by hd-001 or 01 or 1 or te or t or tes or test)..

pl help me..

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-11-02 : 03:36:55
So do you want to use same parameter for both id and hdcasename columns?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

haroon2k9
Constraint Violating Yak Guru

328 Posts

Posted - 2010-11-02 : 03:48:17
YES MADI
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-11-02 : 04:21:25

where (id=replace(@searchparam,'hd-','')*1 or hdcasename =@searchparam)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-11-02 : 04:32:56
quote:
Originally posted by haroon2k9

hi ,

tbl name :Detailstbl

column - id(int),hdcasename :varchar(255)
id hdcasename

1 test

2 tree

3 school


just do the search by id or hdcasename is the parameter..


example searchparam : hd-001 (input param)
result :
id hdcasename
1 tes

input can be : test

result

id hdcasename
1 test


this is all abt the req(inbput param can be id prefixed by hd-001 or 01 or 1 or te or t or tes or test)..

pl help me..




Why cant you have 2 parameters?One for id and one for name?

PBUH

Go to Top of Page

haroon2k9
Constraint Violating Yak Guru

328 Posts

Posted - 2010-11-02 : 05:56:19
quote:
Originally posted by madhivanan


where (id=replace(@searchparam,'hd-','')*1 or hdcasename =@searchparam)

Madhivanan

Failing to plan is Planning to fail



Working as expected..thanks..can you pl explain me what is that *1 do?please
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-11-02 : 06:06:08
It convert the varchar 001 to int 1

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

haroon2k9
Constraint Violating Yak Guru

328 Posts

Posted - 2010-11-02 : 09:15:06
thanks.sorry for the dealyed reply..
Go to Top of Page
   

- Advertisement -