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 2008 Forums
 Transact-SQL (2008)
 Help Required in Stored Procedure

Author  Topic 

njleye
Starting Member

3 Posts

Posted - 2011-12-21 : 02:57:26

Dear All,

I have made a StoreProcedure ( SP may return any text match (with text box whichever data is entered by user) contain in address field of database.) having below select query to get the data using wildcard parameter;

SELECT * from ledg where Address = '%@Address%'

Now the required data of above query is not being received, as SP created successfully.

Kindly help me in this matter if it is possible at your end.

Best Regards,

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-12-21 : 03:03:19
You need to execute it to get the result

EXEC procedure_name

Madhivanan

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

sql-programmers
Posting Yak Master

190 Posts

Posted - 2011-12-21 : 04:01:32
Hi,

You SELECT Statement is wrong.
Use LIKE Statement instead of '='. same time dont write like bcoz u parameter varible inside the quotes. this query will find '@Address' word in Address column.

SELECT * from ledg where Address = '%@Address%'


SO Use below SP it may help.

alter proc upcGetResult
@Address varchar(255)
AS
SELECT * from ledg where Address like '%'+@Address+'%'

Go

SQL Server Programmers and Consultants
http://www.sql-programmers.com/
Go to Top of Page
   

- Advertisement -