Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have following querry:

DECLARE @A int
Declare @R int
EXEC SP_EXECUTESQL N'select new from tblMRM where [year]=year(getdate()) and [month]=CONVERT(CHAR(4), getdate(), 100)', N'@A VARCHAR(10) OUTPUT', @A OUTPUT
select @A


it has following output:
new
0
(No column name)
NULL


When I execute query without select @A,its fine and output is
0
but when I use Select @A, output is
NULL

how can i get this query result

Please Help...
Posted

1 solution

try below query:-

SQL
DECLARE @A int
Declare @R int
EXEC SP_EXECUTESQL N'select @A=new from tblMRM where [year]=year(getdate()) and [month]=CONVERT(CHAR(4), getdate(), 100)', N'@A VARCHAR(10) OUTPUT', @A OUTPUT
select @A

your @a is output parameter and you must use it in sql query..
 
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