I have the following code
USE [database]
GO
/****** Object: StoredProcedure [dbo].[spPacienteEnCola] Script Date: 02/23/2017 08:31:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[spPacienteEnCola]
@tabla varchar(20) = '',
@donde varchar(50) = '',
@funcion int = 0
AS
begin
declare @VConsulta varchar(max) = ''
declare @msg varchar(max) = ''
if @funcion = 0
begin
set @msg = N'No has enviado el valor de @funcion'
print @msg
end
if @funcion = 1
begin
set @VConsulta = 'select * from ' + @tabla + ' where ' + @donde
exec(@vConsulta)
end
end
In function 1, which makes the selection, I need to obtain the value of the Time column and compare it with the current time, but I can not find the way to get the value of the record since the procedure sends me the complete datatable, or the complete record. Help.
Even putting select hora
, it's fine, it returns the time, but not as a data, but as a datatable. What I want is to have that data and assign it to a variable with set @hora = Hora_de_registro_en_bd