Questions tagged as 'sql-server'

1
answer

Where based on the value of a variable

I'm working on migrating an API to a new platform and this includes migrating the queries that were previously written directly into the code for functions in the database. One of the problems I've been facing is that some of the checks we made...
asked by 16.08.2018 / 17:26
3
answers

I can not average

I'm not able to make the sum between qtd_itens_bought and count_count. The query runs normal, at the frequency the result is the same as the amount of items that comes from the "qtd_itens_compra". In short, I would like to add up all the items a...
asked by 13.08.2018 / 16:49
1
answer

Is it possible to perform a filter through a calculated column?

Gentlemen, I am performing the following select in my database. SELECT TOP 5 A.APELIDO, A.REALIZADO, A.META, CAST((A.REALIZADO/A.META)*100 AS DECIMAL(10)) AS ACUMULADO, DENSE_RANK() OVER (ORDER BY ((A.REALIZADO/...
asked by 09.10.2018 / 14:42
1
answer

Subtraction between two fields of same value does not give zero- SQL Server

Someone could explain me: I made a join between two tables. Both bring the same value in their fields. And when I subtract one value minus the other, it does not give zero. How is this possible? E1_SALDO = 990,42 BAIXZ0 = 990,42 SUBTRACA...
asked by 09.10.2018 / 15:13
2
answers

Trigger automatically locks the table (LOCK TABLE)?

About TRIGGER in any table: Does TRIGGER lock (LOCK) the table until the end of its execution? If not, when should I block it? How do I block this?
asked by 27.08.2018 / 15:29
1
answer

Query Result to be Zero

Good afternoon, I have a question, could you help me? ... What happens is: I have a sql query that brings me the total amount of sms sent per month and year, but I wish when I did not get that month it shows zero in the field. because i...
asked by 26.07.2018 / 22:33
1
answer

Select does not return repeated based on a column

I came across a situation where I have a client registry that can have more than one address in the related tbEndereco table and an address can belong to more than one client. But when I query clients I need to return only 1 of those addresses,...
asked by 25.07.2018 / 12:31
1
answer

When the property is not int such as forcing the entity to create a field in the table as nullable: false

The migration is generating the name field in the table as nullable: true I do not want it to be true, how do I solve this problem? public class Professor { public string Id { get; set; } public string Nome { get; set; } public s...
asked by 31.10.2018 / 19:55
1
answer

SQL Server - Trigger does not execute after a given field

I have the trigger below: CREATE TRIGGER AtualizaDataAlteracaoSegmentos ON dbo.Segmentos AFTER INSERT,UPDATE AS BEGIN Begin tran update Segmentos set DataAlteracao = GETDATE() where Id = (select ID from inserted);...
asked by 17.07.2018 / 19:16
2
answers

Sort date by month

In the development of a query, I'm having a month-sorting problem. For example, in the chart I appear first April, then January, June, August ... And what I wanted to get was the order of those same months, January 1, February, March ... Que...
asked by 03.08.2018 / 19:47