somerone can help me please:
I need to convert datetime2(7) from 2012-07-29 10:53:33.0100000 to 29/07/2012 10:53:33 into my store procedure on my sql server
i have this problem with t888_fecact and t888_feciof
y tried this but is not working:
SET @Tabla = 'mitabla'
SET @Objeto = @BaseDatos+'.'+@Schema+'.'+@Tabla
-- Elimina tabla si exite
SET @TSQL = 'if object_id('''+@Objeto+''',''U'') IS NOT NULL DROP TABLE '+@Objeto
EXEC (@TSQL)
-- Sentencia OPENQUERY
SET @OPENQUERY = 'Select t888_numruc,
t888_area,
t888_feciof,
t888_estado,
t888_numreg,
t888_indice,
t888_userna,
t888_fecact,
cast(getdate() as datetime) as today
into '+@Objeto+'
FROM OPENQUERY('+ @LinkedServer + ','''
-- Sentencia TRANSCT-SQL
SET @TSQL = 'Select t888_numruc,
t888_area,
t888_feciof,
t888_estado,
t888_numreg,
t888_indice,
t888_userna,
t888_fecact,
to_char(today,''''%m/%d/%Y %H:%M:%S'''') as today
from '+@Tabla+'
'')'
-- Ejecutamos sentencia OPENQUERY y TRANSCT-SQL
EXEC [sprc].[mensaje_tabla] @Tabla, 'I'
EXEC (@OPENQUERY+@TSQL)
EXEC [sprc].[mensaje_tabla] @Tabla, 'F'
New contributor
Manuel Silva is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.