Questions tagged as 'sql'

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
4
answers

Is it possible to place an "IF" condition on the means to the inner joins and other conditions of a where in SQL Server?

I have a procedure that takes a parameter that can be 0, 1 or 2. When it is 1 or 0, it needs to consider the line where it has "and bol_portfolio = @eh_port", but when it is 2, it can not enter it condition, just bypassing this code. It is possi...
asked by 01.06.2016 / 18:50
2
answers

Group by two fields ordered by a third party

I have the following data: |--------------------------------------------------------| |USER | ID | DEVICEID | DATE | |--------------------------------------------------------| |7 | 14450 | aa6603ceef3b397c | 2...
asked by 03.08.2016 / 15:34
1
answer

How to measure the amount of disk space required for an ALTER TABLE operation?

I need to make some changes to one of the tables to add new columns. The problem is that I can not at all. I get the following error:   PG: DiskFull: ERROR: could not extend file "base / 1672994 / 5557167.4":   No space left on device. HINT:...
asked by 08.04.2016 / 12:52
1
answer

how to add a value per parameter to a select statement in sql within a simple table-valued function?

This is my code and wanted to add a value to a select statement that is passed as parameter for a simple table-valued function. Here is my code: CREATE FUNCTION NMELHORESFORNECEDORES(@N INT ) RETURNS TABLE AS RETURN SELECT TOP @N/*da erro ne...
asked by 28.04.2016 / 18:13
1
answer

How to return a SQL with result?

I need to select multiple tables bound by the "user id" and return the data to compose a profile page, however some of those tables may be empty at first, ie the query will not find the "id user "in one of them and will return an error or no dat...
asked by 15.07.2016 / 14:06
1
answer

Redo autoincrement in SQLite

I'm passing data from an old bank to a new bank. After executing all querys there were some primary key fields that were "missing". Example the id column jumped from die '11' to '13' since die '12' was deleted. This occurs in several ca...
asked by 12.06.2016 / 22:34
1
answer

SQL to know which last edited record

I have the following SQL: $dcadastroultimo = date("d.m.y"); $sqlidcidade = "select id, titulo, tipo from imoveis where cod = '$cliente' AND ueditado <= '$dcadastroultimo' ORDER BY id ASC"; I need you to list the last edited records, but...
asked by 15.03.2016 / 18:13
1
answer

Left Join repeat tables

I'm trying to mount a select that has the result below: With the select below I can see null in only one column. How could I make it work for 20? I have item_1 through item_20 and the item description is in the parts table, in the occ...
asked by 07.03.2016 / 19:05
1
answer

Check 2 and 10 days before and 2, 5 and 10 after the due date

Every month I need to send messages to 10 and 2 day customers and 2, 5 and 10 days days on the Day of Expiration , I have already broken my head and I do not know how to do it: IF OBJECT_ID('tempdb..#TBcontrato') IS NOT NULL DROP TA...
asked by 22.05.2016 / 22:39