Questions tagged as 'sql'

1
answer

Add column as identifier

Greetings, I am working with a table that does not have a column to be able to identify the rows, that is, it does not have a identity which causes me a problem because I need to obtain information from a column of each one of the records...
asked by 23.02.2018 / 22:36
1
answer

How to get the most characters stored in a column of a table?

I have a table products where the column code is a TINYTEXT . When trying to create a foreign key ( FOREING KEY ) I get this error:    # 1170 - Column BLOB column 'code' used in key specification without key size...
asked by 16.02.2018 / 17:06
2
answers

How to make an UPDATE on a BD SQL Server from C Sharp

I have the following code which makes the query. private void EditarUsuario() { miconexion.Open(); string sql = @"UPDATE USUARIOS SET [USUARIO] = @USUARIO, [CLAVE] = @CLAVE"; SqlComm...
asked by 08.03.2017 / 06:05
2
answers

How to get two fields from the same table in SQL through a query

What I want is to get from the same vista or consulta two fields of the same column but with different value, this means that I must recover two different values within a same column, one value is old or obsolete and the other valu...
asked by 03.03.2017 / 17:22
2
answers

How to perform a delete with in (select)?

I have the following query DELETE FROM abono where id='dos' in (select * FROM abono WHERE id='dos' limit 2,1) but my mysql tells me #1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' my table is c...
asked by 27.03.2018 / 05:18
2
answers

Dynamic SQL, Knowing if DB exists SQL 2008?

I raise my problem. I have a SQL Server 2008 Database Server in which new bases are constantly being created, many of them are also erasing them and I do not have full knowledge of how the logging works, because I can actually see which bases ha...
asked by 06.02.2018 / 15:10
3
answers

Sum of NULL problem with result, if the value of the data is null

I need to bring the sum of 2 data: dato1 = 1 dato2 = 2 totalsuma = 3 Currently I do it like this: SET totalsuma = (SELECT SUM(dato1+dato2) from tabla WHERE CODIGO = codigo_new); up there all right the totalsum variable takes me the...
asked by 27.06.2018 / 00:36
1
answer

How to create an email automatically in SQL [closed]

At the time of entering the names and surnames (maternal and paternal) create an email with its first two letters. Example:    Armando Casas Sanchez = [email protected]     
asked by 04.07.2018 / 10:07
2
answers

How to bring data without registration in an sql query? [closed]

In a query sql would like to bring users who are not registered in a defined group, EXAMPLE: I have 10 registered users in my database, but of those 10 there are 5 registered in the GRUPO1 , the idea is to show the other 5 that a...
asked by 18.01.2018 / 18:51
2
answers

problem getting the number of the day of the week on sql server

I have the following query SELECT DATEPART(WEEKDAY,'2018-01-18') What I want is an example that if that day is Thursday, I return a 3 because in the table that I have the days start from 0 to 6 the field is of type int and is called DAYI...
asked by 18.01.2018 / 15:06