Ver Mensaje Individual
  #5 (permalink)  
Antiguo 12/04/2007, 09:34
daniel00
 
Fecha de Ingreso: noviembre-2006
Ubicación: México
Mensajes: 866
Antigüedad: 18 años, 3 meses
Puntos: 8
Re: Cómo generar variable table

Que tal Mahalo.

Sí, se puede, aunque todo tu código quedaría dentro de cadenas de SQL, similar a lo que te propuse anteriormente, sería algo com lo siguiente:

Código:
DECLARE @strSQL varchar(800)
DECLARE @strmyTable varhcar(10) 

SET @strmyTable = 'mytbale'

SET @strSQL = 'DECLARE myCursor CURSOR FOR ' +
                ' SELECT myField1, myFiled2 FROM' + @strmyTable  + ' WHERE ...'

SET @strSQL = @strSQL  ' OPEN myCursor'
....
--- y así seguir agregando el script en una cadena.
....
EXECUTE (@strSQL)
Saludos y suerte!!