Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sp_executesql returning blank resultset
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

subhaoviya
Posting Yak Master

India
135 Posts

Posted - 05/08/2013 :  06:41:05  Show Profile  Reply with Quote
hi while i am executing the below query, i am getting resultset with columns but no data.

DECLARE @sql NVARCHAR(max)
DECLARE @params NVARCHAR(4000)

SET @sql=N'exec MyStoredProcedure'
SET @params = N' @POSTCODE VARCHAR(20), @SURNAME VARCHAR(50),@HOMEPHONE VARCHAR(20),@MOBILE VARCHAR(20)
,@EMAIL VARCHAR(120) ,@D_INDIVIDUALID VARCHAR(200),@P_LEADID VARCHAR(200)'


EXECUTE SP_Executesql @sql,@params,'','','','','',1,''

but when i am executing
exec MyStoredProcedure @D_INDIVIDUALID =1

please help me to resolve the issue with sp_executesql

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 05/08/2013 :  06:49:39  Show Profile  Reply with Quote
it should be

DECLARE @sql NVARCHAR(max) 
DECLARE @params NVARCHAR(4000)

SET @sql=N'exec MyStoredProcedure @POSTCODE,@SURNAME,...'
SET @params = N' @POSTCODE VARCHAR(20), @SURNAME VARCHAR(50),@HOMEPHONE VARCHAR(20),@MOBILE VARCHAR(20)
,@EMAIL VARCHAR(120) ,@D_INDIVIDUALID VARCHAR(200),@P_LEADID VARCHAR(200)'


EXECUTE SP_Executesql @sql,@params,@POSTCODE=<value>,@SURNAME=<value>,...


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

subhaoviya
Posting Yak Master

India
135 Posts

Posted - 05/08/2013 :  06:57:20  Show Profile  Reply with Quote
Thanks a lot visakh it is working fine .
Go to Top of Page

zhulin
Starting Member

3 Posts

Posted - 05/08/2013 :  09:32:21  Show Profile  Reply with Quote
Thank you for sharing. Hope you will share more ideas and pictures, I wish you good luck.



__________________
zhulin
unspammed
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 05/08/2013 :  12:31:32  Show Profile  Reply with Quote
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000