Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Can any one explain what is the use of Sp_executesql in sql server.
Thanks in advance.
Posted
Comments
Magic Wonder 10-Mar-15 6:56am    
You can google it.
Schatak 13-Mar-15 8:33am    
Best answer :)

Use of Sp_executesql?

*.Its support parameter Substitution.

*.Reusing The Execution Plans.

https://technet.microsoft.com/en-us/library/ms175170%28v=sql.105%29.aspx[^]
 
Share this answer
 
Executes a Transact-SQL statement or batch that can be reused many times, or one that has been built dynamically. The Transact-SQL statement or batch can contain embedded parameters.

example

declare @SQLstring nvarchar (500) = 'select getdate()'
declare @parmdefination navarchar(500);

exec sp_executesql @SQLString, @ParmDefinition

it will return current date time..

same as we can run stored procedure.

hope this will help you.
 
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