Return to Snippet

Revision: 70785
at March 11, 2017 05:03 by systemergon


Updated Code
//Reiniciar el contador
DBCC CHECKIDENT ('Schema.Tabla', RESEED,0) 


select * into SchemaDestino.SACPaginasWeb from SchemaOrigen.INCPaginasWeb


Obtener el ultimo d���­a del mes

select eomonth('2015-02-01')

select eomonth(getdate())


//Gererar las clases de la capa Entity

--#Region "Propiedades"

 select 
 concat('Public Property ', column_name, '() as ', DATA_TYPE )
 from INFORMATION_SCHEMA.Columns 
 where Table_name='SACBIENES'

--#End Region


--Revision de conversion sea correcta
 select 
  concat('Byval ', column_name, ' as ', DATA_TYPE ) as TYPESQL,
  concat('Byval ', column_name, ' as ', net.dbtype ) as TYPENET
 from INFORMATION_SCHEMA.Columns 
 left join ActivoFijo.SQLDOTNET net on DATA_TYPE = net.SqlDbType
 where Table_name='SACBIENES'
 
 
 --#Region "Constructores" 
  
 --Variables
DECLARE @variables AS NVARCHAR(500); 
SET @variables = (
select STUFF(
											(
											select 
RTRIM( LTRIM(
 concat(',', 'Byval ', column_name, ' as System.', net.dbtype ,' ')
 ))

 from INFORMATION_SCHEMA.Columns 
 left join ActivoFijo.SQLDOTNET net on DATA_TYPE = net.SqlDbType
 where Table_name='SACBIENES'

										FOR XML PATH (''))
										, 1, 1, '') AS CCSR) 


		--select @variables 
		SELECT CONCAT('Public Sub New(', @variables , ASCII(10),') End Sub')



--Asignaciones 
 select 
  concat('Me.', column_name, ' = ', column_name )
 from INFORMATION_SCHEMA.Columns 
 where Table_name='SACBIENES'


--#End Region


-----------------------------------------------------------------------------------
-- CAPA BL
-- #Region "Propiedades"
Declare @salto as varchar= CHAR(13) + CHAR(10);
select 
RTRIM( LTRIM(
 concat('Public Property ', column_name, '() as System.', net.dbtype , @salto ,
 ' Get ' , @salto ,
 ' Return Me.',Table_name, '.', column_name , @salto,
 ' End Get ', @salto, 
 ' Set (value as System.', net.dbtype ,')', @salto,
 '  Me.',Table_name, '.', column_name ,' = value ', @salto,
 'End Set ', @salto,
 'End Property', @salto

 )
 ))

 from INFORMATION_SCHEMA.Columns 
 left join ActivoFijo.SQLDOTNET net on DATA_TYPE = net.SqlDbType
 where Table_name='SACBIENES'

 --#End Region



 --#Region "Constructores" 
  
 --Variables
Declare @saltoC as varchar= CHAR(13) + CHAR(10);
DECLARE @variablesC AS NVARCHAR(1000); 
SET @variablesC = (
select STUFF(
											(
											select 
RTRIM( LTRIM(
 concat(',', 'Byval ', column_name, ' as System.', net.dbtype ,' ')
 ))

 from INFORMATION_SCHEMA.Columns 
 left join ActivoFijo.SQLDOTNET net on DATA_TYPE = net.SqlDbType
 where Table_name='SACBIENES'

										FOR XML PATH (''))
										, 1, 1, '') AS CCSR) 

	
		SELECT CONCAT('Sub New()'[email protected] +'End Sub'[email protected]+'Public Sub New(', @variablesC , ASCII(10),')' + @saltoC  + ' End Sub')


--Asignaciones 
 select 
  concat('Me.', column_name, ' = ', column_name )
 from INFORMATION_SCHEMA.Columns 
 where Table_name='SACBIENES'




--#End Region

Revision: 70784
at August 5, 2016 05:14 by systemergon


Updated Code
select * into SchemaDestino.SACPaginasWeb from SchemaOrigen.INCPaginasWeb


Obtener el ultimo d�­a del mes

select eomonth('2015-02-01')

select eomonth(getdate())


//Gererar las clases de la capa Entity

--#Region "Propiedades"

 select 
 concat('Public Property ', column_name, '() as ', DATA_TYPE )
 from INFORMATION_SCHEMA.Columns 
 where Table_name='SACBIENES'

--#End Region


--Revision de conversion sea correcta
 select 
  concat('Byval ', column_name, ' as ', DATA_TYPE ) as TYPESQL,
  concat('Byval ', column_name, ' as ', net.dbtype ) as TYPENET
 from INFORMATION_SCHEMA.Columns 
 left join ActivoFijo.SQLDOTNET net on DATA_TYPE = net.SqlDbType
 where Table_name='SACBIENES'
 
 
 --#Region "Constructores" 
  
 --Variables
DECLARE @variables AS NVARCHAR(500); 
SET @variables = (
select STUFF(
											(
											select 
RTRIM( LTRIM(
 concat(',', 'Byval ', column_name, ' as System.', net.dbtype ,' ')
 ))

 from INFORMATION_SCHEMA.Columns 
 left join ActivoFijo.SQLDOTNET net on DATA_TYPE = net.SqlDbType
 where Table_name='SACBIENES'

										FOR XML PATH (''))
										, 1, 1, '') AS CCSR) 


		--select @variables 
		SELECT CONCAT('Public Sub New(', @variables , ASCII(10),') End Sub')



--Asignaciones 
 select 
  concat('Me.', column_name, ' = ', column_name )
 from INFORMATION_SCHEMA.Columns 
 where Table_name='SACBIENES'


--#End Region


-----------------------------------------------------------------------------------
-- CAPA BL
-- #Region "Propiedades"
Declare @salto as varchar= CHAR(13) + CHAR(10);
select 
RTRIM( LTRIM(
 concat('Public Property ', column_name, '() as System.', net.dbtype , @salto ,
 ' Get ' , @salto ,
 ' Return Me.',Table_name, '.', column_name , @salto,
 ' End Get ', @salto, 
 ' Set (value as System.', net.dbtype ,')', @salto,
 '  Me.',Table_name, '.', column_name ,' = value ', @salto,
 'End Set ', @salto,
 'End Property', @salto

 )
 ))

 from INFORMATION_SCHEMA.Columns 
 left join ActivoFijo.SQLDOTNET net on DATA_TYPE = net.SqlDbType
 where Table_name='SACBIENES'

 --#End Region



 --#Region "Constructores" 
  
 --Variables
Declare @saltoC as varchar= CHAR(13) + CHAR(10);
DECLARE @variablesC AS NVARCHAR(1000); 
SET @variablesC = (
select STUFF(
											(
											select 
RTRIM( LTRIM(
 concat(',', 'Byval ', column_name, ' as System.', net.dbtype ,' ')
 ))

 from INFORMATION_SCHEMA.Columns 
 left join ActivoFijo.SQLDOTNET net on DATA_TYPE = net.SqlDbType
 where Table_name='SACBIENES'

										FOR XML PATH (''))
										, 1, 1, '') AS CCSR) 

	
		SELECT CONCAT('Sub New()'[email protected] +'End Sub'[email protected]+'Public Sub New(', @variablesC , ASCII(10),')' + @saltoC  + ' End Sub')


--Asignaciones 
 select 
  concat('Me.', column_name, ' = ', column_name )
 from INFORMATION_SCHEMA.Columns 
 where Table_name='SACBIENES'




--#End Region

Revision: 70783
at August 4, 2016 05:50 by systemergon


Updated Code
select * into SchemaDestino.SACPaginasWeb from SchemaOrigen.INCPaginasWeb


Obtener el ultimo día del mes

select eomonth('2015-02-01')

select eomonth(getdate())


//Gererar las clases de la capa Entity

--#Region "Propiedades"

 select 
 concat('Public Property ', column_name, '() as ', DATA_TYPE )
 from INFORMATION_SCHEMA.Columns 
 where Table_name='SACBIENES'

--#End Region


--Revision de conversion sea correcta
 select 
  concat('Byval ', column_name, ' as ', DATA_TYPE ) as TYPESQL,
  concat('Byval ', column_name, ' as ', net.dbtype ) as TYPENET
 from INFORMATION_SCHEMA.Columns 
 left join ActivoFijo.SQLDOTNET net on DATA_TYPE = net.SqlDbType
 where Table_name='SACBIENES'
 
 
 --#Region "Constructores" 
  
 --Variables
DECLARE @variables AS NVARCHAR(500); 
SET @variables = (
select STUFF(
											(
											select 
RTRIM( LTRIM(
 concat(',', 'Byval ', column_name, ' as System.', net.dbtype ,' ')
 ))

 from INFORMATION_SCHEMA.Columns 
 left join ActivoFijo.SQLDOTNET net on DATA_TYPE = net.SqlDbType
 where Table_name='SACBIENES'

										FOR XML PATH (''))
										, 1, 1, '') AS CCSR) 


		--select @variables 
		SELECT CONCAT('Public Sub New(', @variables , ASCII(10),') End Sub')



--Asignaciones 
 select 
  concat('Me.', column_name, ' = ', column_name )
 from INFORMATION_SCHEMA.Columns 
 where Table_name='SACBIENES'


--#End Region

Revision: 70782
at August 4, 2016 02:15 by systemergon


Updated Code
select * into SchemaDestino.SACPaginasWeb from SchemaOrigen.INCPaginasWeb


Obtener el ultimo día del mes

select eomonth('2015-02-01')

select eomonth(getdate())

Revision: 70781
at July 8, 2016 01:24 by systemergon


Initial Code
select * into SchemaDestino.SACPaginasWeb from SchemaOrigen.INCPaginasWeb

Initial URL


Initial Description
De las tareas que día a día necesitamos realizar en una base de datos

Initial Title
SQL Server día a día

Initial Tags
copy

Initial Language
SQL