SQL Server Forums
Profile | Register | 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
 insert into a table exec sp_executesql @strSql
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

aoriju
Posting Yak Master

India
156 Posts

Posted - 10/04/2012 :  09:12:17  Show Profile  Reply with Quote
Hi all,

How to insert a sp_executesql statement
Example:
insert into [dbo].[tbl_ETS_DataHolder]
exec sp_executesql @strSql WITH RECOMPILE;

Edited by - aoriju on 10/04/2012 09:22:55

webfred
Flowing Fount of Yak Knowledge

Germany
8765 Posts

Posted - 10/04/2012 :  09:23:31  Show Profile  Visit webfred's Homepage  Reply with Quote
Did you try what you have posted?
Is the result not what you need?
Are there any error messages?


Too old to Rock'n'Roll too young to die.
Go to Top of Page

aoriju
Posting Yak Master

India
156 Posts

Posted - 10/04/2012 :  09:27:33  Show Profile  Reply with Quote
not getting any error...but data not inserted
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8765 Posts

Posted - 10/04/2012 :  09:36:15  Show Profile  Visit webfred's Homepage  Reply with Quote
is there any output if you run that exec... without insert?


Too old to Rock'n'Roll too young to die.
Go to Top of Page

aoriju
Posting Yak Master

India
156 Posts

Posted - 10/04/2012 :  09:38:30  Show Profile  Reply with Quote
yes output is there..do we need any out parameter or ?..then pls provide the syntax
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8765 Posts

Posted - 10/04/2012 :  09:47:47  Show Profile  Visit webfred's Homepage  Reply with Quote
On the given information I can say: it should work.
But I can't see what you are really doing.

Is this little test working for you?
declare @sql nvarchar(max)
set @sql = 'select ''Test'''
create table #sample (testcol varchar(255))
insert #sample
exec sp_executesql @sql with recompile

select * from #sample
drop table #sample



Too old to Rock'n'Roll too young to die.
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2210 Posts

Posted - 10/04/2012 :  09:48:48  Show Profile  Reply with Quote
Check these links. You can get idea....

http://www.kodyaz.com/articles/tsql-sp_executesql-with-output-parameters.aspx
http://msdn.microsoft.com/en-us/library/ms188001.aspx


--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.08 seconds. Powered By: Snitz Forums 2000