Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have this code for filtering data from table

SQL
create proc [dbo].[DataDetailsFilter_proc]

@filter varchar output

as
set nocount on

SELECT *
FROM DataDetails
WHERE FirstName = @filter


but it's not working

it gets back with nothing

FirstName is the name of the column and when I instead of @filter type this

WHERE FirstName = 'MYNAME'

then it works, but I need to type in that parameter
Posted

Thats because your parameter varchar.. You have to set the size of varchar.Else it will take only one character..

Try this.

SQL
create proc [dbo].[DataDetailsFilter_proc]
 
@filter varchar(100) output
 
as
set nocount on
 
SELECT *
FROM DataDetails
WHERE FirstName = @filter
 
Share this answer
 
Comments
shonezi 24-Sep-12 3:32am    
Thanks Santhos!!! I am such a begginer :)
Santhosh Kumar Jayaraman 24-Sep-12 3:33am    
You are welcome
Hi,

You cann't use Stored Procedure in Select statement its incorrect syntax,

Exec DataDetailsFilter_proc 'MYNAME'

it will work.
 
Share this answer
 
it works for me though. It should be working
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900