Questions tagged as 'sql-server'

1
answer

Create procedure to adjust price according to conditions (SQL Server) [closed]

In a DB of a bookstore I need to create a procedure to readjust the price column according to the percentage and gender reported (using transaction control). How should I do it? create table livro ( liv_ID int not null constraint PKcod_li...
asked by 26.10.2016 / 23:43
2
answers

PHP error with SQLserver exception 'PDOException' with message 'SQLSTATE [08001]: [Microsoft] [ODBC Driver 11 for SQL Server]

I installed the driver right in PHP, I added the extension in php.ini , but when I try to connect with PDO in sqlserver, this error appears:    exception 'PDOException' with message 'SQLSTATE [08001]:   [Microsoft] [ODBC Driver 11 for S...
asked by 14.09.2016 / 21:48
1
answer

Calculation of string occurrence

I have a table with 3 columns id , nome and voto . They are populated with many records, and I need a calculation that returns the name with the best "balance" of votes . The voto column can only receive values like 'y...
asked by 22.08.2016 / 19:12
1
answer

Running Data Bank SQL Server External HD

I'm starting to build a Web application using SQL Server and I talked to my client to make the database backup available, avoiding access to their production base, since it does not have a certification base. The 10GB .bak was generated where it...
asked by 19.10.2016 / 02:54
1
answer

How to use having together with view in sql server

When trying to use HAVING in a SQL query is returning the following error: Mensagem 8121, Nível 16, Estado 1, Linha 15 Column 'V_DADOSFUNC.FILIAL' is invalid in the HAVING clause because it is not contained in either an aggregate funct...
asked by 18.10.2016 / 20:23
2
answers

How to create a FOREIGN KEY using uniqueidentifier in SQL Server

Hello, I'd like some help. I have a table in SQL called Client, which has as primary key a type uniqueidentifier Ex: Create table Cliente ( ClienteID uniqueidentifier not null, Nome varchar(50) ) I'd like to know...
asked by 19.07.2016 / 17:20
3
answers

INSERT within a SELECT - SQL Server

I need to do an INSERT within a SELECT in some cases in my Query. An example of how I need to: SELECT IdTabela, Nome, CASE WHEN IdTabela > 10 THEN INSERT INTO TabelaExemplo (IdTabelaExempl...
asked by 19.07.2016 / 22:51
1
answer

Write log of a field only if it is insert (trigger SQL Server)

I have a trigger that fires when insert / update FOR UPDATE, INSERT I check if the field has changed with: if update (nome) --faça algo How do I know if I am inserting a record in the table to be able to record a log?     
asked by 20.07.2016 / 15:42
1
answer

Get the database time sql server formatted

My database has a difference of 4 hours, support so far has not given a solution, so I would like to know how I can format the time out: select CAST(HORA_FECHAMENTO AS datetime) as HORA_FECHAMENTO, CONVERT(VARCHAR(05), DATEADD(hour, +4, getda...
asked by 14.07.2016 / 16:34
1
answer

Change accented characters to unaccented ones

Is there any kind of method for me to do a replace in characters based on the CASE of the same? I'm looking for something like this: UPDATE foo SET bar = SUBSTRING(bar, "Ã","ã"); -- se o caracter for LOWER -> ã -- se o caracter for UPPER...
asked by 30.08.2016 / 18:45