Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: exec ()


Message #1 by "Win, Ann" <AWin@a...> on Mon, 2 Apr 2001 19:05:26 -0700
Hi
   I have 2 procedures like this

/*----------------------------------------------------
 * proc 2, called by proc 1
 ----------------------------------------------------*/
create proc proc2 (@dom char (3), @subdSeq varchar (255) output)
as

/***************************************************
 * I like to say "select @subDSeq = seq from HI2"
   so I constructed a string like this
 ***************************************************/

	declare @temp varchar (255)
	set @temp = "select @subDSeq = seq from l_" + @dom
	exec (@temp)

/***************************************************
   of course it does not work, I have an error message
   Must declare the variable '@s...'.
 ***************************************************/
go


/*----------------------------------------------------
 * proc 1
 ----------------------------------------------------*/
create proc proc1
as
   exec proc2 ('hi2', @sudomain output)
go

/***************************************************
  this probably is a very dumb example, but 
  I just want to know is there any way to 
  execute that kind of statements.  Thanks
  a lot
****************************************************/

  Return to Index