| Author |
Topic  |
|
|
sweet_777
Starting Member
16 Posts |
Posted - 10/07/2010 : 02:16:34
|
Hi all,
I am passing concatenated column values as input parameter to the stored procedure.
concatenated column contains suppose 5 columns, that 5 columns contains null values, empty values, values.
i writing sp like this:
ALTER proc SP_DisplayEmail ( @value varchar(1000), @siteid int ) as
DECLARE @Query varchar (1000) begin SET @Query = 'select ' + @value + ' from emp where siteid= ' + CONVERT (varchar (10),@siteid) PRINT(@Query) EXEC(@Query) end
but i am getting null value.
how to check null value and how to written value .
regards rama
Thanks & Regards Sweet_77 |
|
|
pk_bohra
Flowing Fount of Yak Knowledge
India
1182 Posts |
Posted - 10/07/2010 : 04:49:50
|
Any value concatenated with null results in null value.
You need to check whether value is null or not using ISNULL(@variabletocheck,'substitute value or empty value')
|
 |
|
|
Transact Charlie
Flowing Fount of Yak Knowledge
United Kingdom
3442 Posts |
Posted - 10/07/2010 : 04:53:18
|
Read this: http://www.sommarskog.se/dynamic_sql.html
If you take the time to read that link and understand it you'll probably want to rethink your design.
Also -- where are you getting these parameters?
if they come from any front end input then this isn't safe. You are leaving yourself wide open to sql injection attack.
Charlie =============================================================== Msg 3903, Level 16, State 1, Line 1736 The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
| |
Topic  |
|