Questions tagged as 'sql-server'

5
answers

How to calculate the date and code of the shift?

I have a table that specifies the start time of a work shift and its duration in minutes: codigo descricao inicio(datetime) duracao(int) S01 PRIMEIRO 1900-01-01 05:00:00.000 540 S02 SEGUNDO...
asked by 27.10.2017 / 18:56
3
answers

_ (underline) in consultation with LIKE

I'm doing a query where I need to return all the information in a given table, which contains " _R _ " in the nomenclature. However, when using WHERE NM_CAMPAIGN LIKE '%_R_%' it returns me to other cases that only have " R _ ". How...
asked by 16.08.2017 / 14:55
2
answers

Query that returns if the child inherited the surname of the father and / or mother

I have a scenario that I need to sort my records where: Did the child inherit the surname of the father and / or his mother? Notice in the picture that if one of the child's last names exists in the parent's name the PAI? field ge...
asked by 19.04.2017 / 21:40
1
answer

Implications of using inner join and left join on the same select

I have some stored procedures in a SQL Server 2008 R2 database, these stored procedures have several joins , in some cases I used the < , inner join and left join , for example: Tabela Pessoa | IDPessoa | Nome | | 1 | João | |...
asked by 17.12.2014 / 00:55
3
answers

Order SQL for 1,2,3 instead of 1,10,2,3

I have a name field in a table that has the following data:    1-Course       2-Course       10-Course When sorting by name it returns 1,10,2 . How to order to bring: 1,2,10 ? Ps: The field is NVARCHAR .     
asked by 12.08.2014 / 23:26
2
answers

How to get column names from a table in SQL Server?

Languages table: HowdoIselecttheColumnNamesofthistable?Theresultwouldbe:"IDIdioma", "Sigla" and "IDioma".     
asked by 02.03.2017 / 14:20
1
answer

How to get the last record entered in SQL according to your date

I need to get a record of a table, where this record is what the date was entered last. Of the genre: SELECT Ped.Quantidade FROM ped WHERE data <= @data But as I have several records it returns me all, when I just want the last one in...
asked by 16.04.2014 / 13:44
2
answers

Sql Server 2014 Null Value

I am a beginner in Sql server, I am doubtful about the following code: declare @var nvarchar(50) = null declare @bool bit if (@var = null) set @bool = 1 else set @bool = 0 print @bool The variable @bool returns as 0...
asked by 23.09.2016 / 23:06
1
answer

Use Cookies or Database?

I need to create a cart where I store more than one Example: ID_PRODUTO , ID_VENDEDOR I would like to use Cookies pro system to be lighter, however I found a big problem, Cookie stores the data in 1 line:    COOKIE VALUE =   ...
asked by 15.03.2014 / 23:52
2
answers

Error trying to update table using C #

I created a form to change a table, but my update is not working. cnxCli.sel =/*"set dateformat dmy \n"+ */ "update Cliente" + "set Nome = '" + txtNome.Text +"'," + "Rg = '" + mskRg.Text +...
asked by 16.12.2015 / 02:32