I have textbox in application. If user type in text box it will search in the table. It basically ItemId
here is my code
Select top 1000 ima_itemid as ItemID, ima_itemName as ItemName from ima
where (ima_itemid LIKE @IMA_ItemID+'%' )
This code is work fine.
Some users need to search more specific in the text box
Example: 110%1
If user type this id it need to select like 1101 _ _ 11, 110_ _ _21, 110 _ _ 61 etc.,
So i used if condition on the sql statement, but it doesnt work
If @IMA_ItemID= N'%'
then
Select top 1000 ima_itemid as ItemID, ima_itemName as ItemName from ima
where (ima_itemid LIKE @IMA_ItemID)
Else
Select top 1000 ima_itemid as ItemID, ima_itemName as ItemName from ima
where (ima_itemid LIKE @IMA_ItemID+'%' )
It means If the user type with' % ' the in my statement i need to remove. If user type only numbers the i want to include. I think i need to do with programming. But i hope we can do also in the sql statement
Thanks in advance ur answer
here is my code
Select top 1000 ima_itemid as ItemID, ima_itemName as ItemName from ima
where (ima_itemid LIKE @IMA_ItemID+'%' )
This code is work fine.
Some users need to search more specific in the text box
Example: 110%1
If user type this id it need to select like 1101 _ _ 11, 110_ _ _21, 110 _ _ 61 etc.,
So i used if condition on the sql statement, but it doesnt work
If @IMA_ItemID= N'%'
then
Select top 1000 ima_itemid as ItemID, ima_itemName as ItemName from ima
where (ima_itemid LIKE @IMA_ItemID)
Else
Select top 1000 ima_itemid as ItemID, ima_itemName as ItemName from ima
where (ima_itemid LIKE @IMA_ItemID+'%' )
It means If the user type with' % ' the in my statement i need to remove. If user type only numbers the i want to include. I think i need to do with programming. But i hope we can do also in the sql statement
Thanks in advance ur answer
Comment