December 6, 2011 at 1:07 am
I have storedprocedure .sql file, it contains content from "create proc ......". I want to run this dynamically.
I select .sql file from one location and read this and send content as an parameter in a storedprocedure. Now i want to run this content. What can i do? pls help me.:-)
December 6, 2011 at 1:48 am
please provide your DDL scripts so that we can assit you better.
December 6, 2011 at 1:58 am
Hi,
I made one sp like as:
Create proc sarvesh
as
Begin
Select 0
end
I want to run this script at client side from my side. I send this as an parameter in string in other sp.
Can you tell me, how can i run this?
December 6, 2011 at 2:13 am
do you want to run the full string including the CREATE PROC, or just the contents of the proc
EG EXEC ProcName or CREATE PROC ProcName.....
Also you have only provided one part of the DDL, we need the other part which is the execution proc
December 6, 2011 at 4:44 am
Hi,
I wrote following syntax:
exec 'Create proc sarvesh as Begin Select 0 end'
but it gives error, pls run this and send me right syntax.
December 6, 2011 at 4:48 am
declare @string varchar(max)
set @string = 'SOME STRING'
sp_executesql (@string)
or
EXEC (@string)
December 6, 2011 at 5:24 am
Sarvesh Kumar Gupta (12/6/2011)
Hi,I wrote following syntax:
exec 'Create proc sarvesh as Begin Select 0 end'
but it gives error, pls run this and send me right syntax.
As anthony said, you can do it using SP_ExecuteSQL like this:
SET QUOTED_IDENTIFIER OFF
GO
DECLARE @SQLText NVARCHAR(MAX)
SET @SQLText = "SELECT 'It is working.'"
Execute SP_ExecuteSQL @statement = @SQLText
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply