Questions tagged as 'sql-server'

1
answer

How to join three queries but from the same Table in SQL SERVER?

I would like to know if you can join three tables but with different conditions, one winged result of the other.    ---- First Consultation ---- --Atenciones Emergencia select year(fecha)*100+month(fecha) as Periodo, NombreM...
asked by 05.11.2018 / 22:20
1
answer

APS.NET MVC stored procedure that returns an array

How can I create a stored procedure that shows me employee deductions I need a result like this: where it shows the uniform deduction This is the table employees is the table deductions this is the Deductions Detail table...
asked by 19.10.2018 / 22:58
1
answer

How can I get a cumulative column that depends on conditions?

I need to find a way to get an accumulated for each of the records (my query currently returns the records per day), I have something like this: SELECT DATEPART(DAY, r.entrega) AS dia, SUM( CASE WHEN (r.tipo = 1 AN...
asked by 25.10.2018 / 19:29
1
answer

Only one expression can be specified in the select list when the subquery is not introduced with EXISTS

This is my query ... DECLARE @fecha0 datetime SET @fecha0 = (select top 1* FROM events WHERE plate like '%D7Z716%' AND CONVERT(varchar, received, 103) = CONVERT(varchar, GETDATE(), 103) AND ADDRESS LIKE '%W BAYER%') IF EXISTS...
asked by 26.10.2018 / 20:28
1
answer

Error inserting timestamp

I have the following sentence ready ...    Query to insert TimeStamp public void insertarValores() throws SQLException{ PreparedStatement ps = null; conectar con = new conectar(); Connection conn = null; conn = con. conect...
asked by 22.09.2018 / 00:24
2
answers

Generate SQL location number

I find the need to generate a code for each record that is inserted in the database and add it to the field NumberRadicate, I searched for documentation but the only one I found is the identity autoincremental but the code must have the letters...
asked by 21.09.2018 / 18:40
1
answer

SQL Switch assigning value to a variable

I need to go through a whole table and depending on its content insert that data somewhere else that I imagine I could use a switch , but I have problems to reference it to the variable I want. I need to recognize the value of [Charge / Credit]...
asked by 22.08.2018 / 19:46
2
answers

get the number of rows of a sql server base to show in php

I want to see the number of rows in a table in SQL server my sentence is: $result12 = sqlsrv_num_rows($conn, "SELECT asistencia FROM asistencia"); but you are not giving me any results when trying to show it in php, taking 100 results in m...
asked by 30.07.2018 / 18:06
1
answer

Problems obtaining data when converting an int to a decimal field.

I have a table with two fields, nombre and cantidad de productos , I'm generating an additional field to see the amount of products consumed in 10 months so I'm doing a select like this: select nombre, existencia , cast((ca...
asked by 21.06.2018 / 23:15
1
answer

Problems with Pivot and Join SQL Server

Could someone tell me what I'm doing wrong? All the errors that mark me tell me the same thing    Expecting '(', or SELECT ( select distinct --periodo empleados.idempleado , conceptos.descripcion descripcion, valconceptos.valor, pe...
asked by 19.09.2018 / 02:31