Questions tagged as 'sql-server'

2
answers

Update in three tables [closed]

Good morning, I wonder if it's possible to update three tables at once? I have the tables booksA, booksB, booksC that are related by column book_id, and I would like to change the value of book_mode column in the three tables at the same time to...
asked by 03.12.2018 / 13:49
2
answers

How to delete duplicate lines without using distinct?

The following query returns the following: IFobject_id('tempdb..#tmpHistorico')ISNOTNULLBEGINDROPTABLE#tmpHistoricoENDCREATETABLE#tmpHistorico(Idintnotnull,IdColuna1intnotnull,IdColuna2intnotnull,Valor1varchar(10)notnull,Valor2varchar(10)not...
asked by 10.04.2018 / 09:49
3
answers

How to generate new code from DBO

I have a table with the name Produtos where I inserted 3 products for testing. Now I'm setting up the product registration form and I need to always generate a sequential product code from the last id already registered + 1. The code I...
asked by 14.07.2016 / 15:26
2
answers

Arrange columns in rows for equal IDs in SQL server

I have a single table with some foreign key records repeated a maximum of 5 times according to entries, eg: id_ok|fornecedor|valor_final|escolha|ativo| -------------------------------------------- o_11 | DOPE |R$ 20800 | SIM | NOK | o_...
asked by 04.12.2015 / 15:48
3
answers

Column outside the WHERE condition of SELECT

I need to make a query that returns a column with the amount of requests the customer made within the period spent in WHERE and together with another column with the total number of requests that the customer has made so far. More or less like t...
asked by 18.12.2014 / 19:11
1
answer

Catch only first word inside a sql server query

Good afternoon, I have the following query SELECT COUNT (SolID) as quant, UsuNome as gerador FROM Solicitacao INNER JOIN Usuario ON Solicitacao.UsuIDAtendenteViaFone = Usuario.UsuID WHERE UsuIDGrupo = 2655 AND DATEPART(m, SolData) = DATEPART...
asked by 03.11.2015 / 19:50
3
answers

Data types in SQL Server 2012 and HTML forms with PHP: date and monetary values

How can I put a mask in an HTML form in the date and monetary value fields, then send that data to the database without having to convert the strings to types date and money ? I explain: I have a form with date mask in DD/M...
asked by 08.12.2015 / 10:54
2
answers

Finding a value in several fields

In my bank I have 3 columns for phone, I need to know if the value is in any of the 3 fields, what is the best way to assemble this select?     
asked by 07.01.2015 / 20:52
3
answers

How to show quantity of sales per form of payment per month in SQL Server

I'm having the following result: Mes | QtdPorMes 1 | 124 2 | 102 3 | 84 4 | 32 I would need it to look like this: Mes | Boleto | Cartão | Total 1 | 100 | 24 | 124 2 | 82 | 20 | 82...
asked by 10.04.2018 / 15:47
3
answers

Do not return value of a field, when it is zero

I am creating a query in SQL , but I need a field not to display the values when it is zero. Is it possible? SELECT gfilial.nomefantasia AS 'Filial', tmov.codtmv AS 'CODTMOV', tmov.numeromov AS 'Número', tmov.valo...
asked by 10.07.2017 / 20:19