Como cambiar el owner de objetos en nuestra base de datos

by Roy Rojas 23. octubre 2009 09:37

Algunas veces cuando importamos una base de datos, ya sea por restore, script o cual sea, esta puede venir asociada a algún usuario, el cual no tenemos en nuestro ambiente de seguridad, ni nos interesaría tenerlo, entonces tenemos que cambiarle a cada objeto el owner al que nosotros definamos.

Con el siguiente código generamos el script necesario para cambiarle el owner a los objetos

select 'exec sp_changeobjectowner ''dbo1046.' + name + ''',''dbo''' from sysobjects
where xtype = 'U'

sp_changeobjectowner recibe dos parámentros, nombre del objeto con el prefijo del owner original y el segundo parámetro sería el nuevo owner con el que quedaría este objeto

xtype indica el tipo de objeto al cual le queremos aplicar el código, tabla, vista, función, etc. Los diferentes tipos de objetos son :

C     CHECK_CONSTRAINT
D     DEFAULT_CONSTRAINT
F     FOREIGN_KEY_CONSTRAINT
FN    SQL_SCALAR_FUNCTION
FS    CLR_SCALAR_FUNCTION
IT    INTERNAL_TABLE
P     SQL_STORED_PROCEDURE
PK    PRIMARY_KEY_CONSTRAINT
S     SYSTEM_TABLE
SQ    SERVICE_QUEUE
TF    SQL_TABLE_VALUED_FUNCTION
TR    SQL_TRIGGER
U     USER_TABLE
UQ    UNIQUE_CONSTRAINT
V     VIEW

 

Tags: , , ,

Bases de Datos | Programación

Comentarios

15/02/2010 7:57:14 #

aloe vera colon cleanse

Nice one - Thanks for sharing dude.

aloe vera colon cleanse United Kingdom

20/02/2010 9:39:57 #

brow gel

Nice blog - I will link to it from my brow gel website.

brow gel United Kingdom

05/03/2010 12:12:56 #

lucien pellat finet cashmere

i run a wordpress blog about lucien pellat finet cashmere, I think I will change to this blogengine system as it is a lot nicer than mine.

lucien pellat finet cashmere United Kingdom

07/03/2010 7:34:16 #

lucien pellat finet cashmere

i run a wordpress blog about lucien pellat finet cashmere, I think I will change to this blogengine system as it is a lot nicer than mine.

lucien pellat finet cashmere United Kingdom

Añadir comentario


(Mostrará su icono Gravatar )

  Country flag

biuquote
  • Comentario
  • Vista previa
Loading



Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen