| Author |
Topic |
|
js.reddy
Yak Posting Veteran
80 Posts |
Posted - 2007-07-12 : 03:25:22
|
| Hi all I have a table called books.The columns are bookid,bookname.I want to write a stored procedure.The parameter is @partname.for example if i give @partname = 'ram'then all books which are related to 'ram' should displaylike bookname-----------The RamaianRamaian by mollaRam Ram RamThe Ramayanam by valmikican any one help me!Thanks. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-07-12 : 04:24:53
|
| Select bookname from tablewhere bookname like '%ram%'Note that this wont make use of index if it is defined on bookname columnMadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-07-12 : 04:31:14
|
| As you use parameter it should be Select bookname from tablewhere bookname like '%+partname+'%'MadhivananFailing to plan is Planning to fail |
 |
|
|
js.reddy
Yak Posting Veteran
80 Posts |
Posted - 2007-07-12 : 04:47:52
|
Hi MadhivananI tried it.But it is not working.can u please check it once again.thank you quote: Originally posted by madhivanan As you use parameter it should be Select bookname from tablewhere bookname like '%+partname+'%'MadhivananFailing to plan is Planning to fail
|
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-07-12 : 05:01:12
|
| Did you get any error?Did you get unexpected error?MadhivananFailing to plan is Planning to fail |
 |
|
|
js.reddy
Yak Posting Veteran
80 Posts |
Posted - 2007-07-12 : 05:04:00
|
| No I did not get any error.but it displays nothing |
 |
|
|
js.reddy
Yak Posting Veteran
80 Posts |
Posted - 2007-07-12 : 05:06:34
|
I think some error is there in your query. like '%+partname+'%'quote: Originally posted by madhivanan Did you get any error?Did you get unexpected error?MadhivananFailing to plan is Planning to fail
|
 |
|
|
js.reddy
Yak Posting Veteran
80 Posts |
Posted - 2007-07-12 : 05:11:33
|
MadhavanHere I am writing my sp. please check it! correct or not !create procedure bookpart@part varchar(100)asbeginselect bookname from books where bookname like '%+@part+%'endquote: Originally posted by madhivanan Did you get any error?Did you get unexpected error?MadhivananFailing to plan is Planning to fail
|
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-07-12 : 05:26:07
|
1 My name is Madhivanan 2 You didnt see my code correctly your sp code should be nowcreate procedure bookpart@part varchar(100)asbeginselect bookname from books where bookname like '%'+@part+'%'endSee how it differs from yoursMadhivananFailing to plan is Planning to fail |
 |
|
|
js.reddy
Yak Posting Veteran
80 Posts |
Posted - 2007-07-12 : 05:31:47
|
Thank you MadhivananNow it is ok.quote: Originally posted by madhivanan 1 My name is Madhivanan 2 You didnt see my code correctly your sp code should be nowcreate procedure bookpart@part varchar(100)asbeginselect bookname from books where bookname like '%'+@part+'%'endSee how it differs from yoursMadhivananFailing to plan is Planning to fail
|
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-07-12 : 06:24:40
|
I hope you know how to execute the SP MadhivananFailing to plan is Planning to fail |
 |
|
|
|