Questions tagged as 'sql-server'

1
answer

SELECT TOP that brings all the results, something like TOP all, exists in SQL Server?

During my studies, I tried to sort the records and put the ones that are NULL at the end, I did the following: SELECT tbl1.firstname, tbl1.mgrid FROM ( SELECT TOP 100 firstname, mgrid FROM HR.Employees...
asked by 29.03.2018 / 16:06
1
answer

Script Generate Excel SQL SERVER

I have a select and I need to generate an excel through it. However there are some observations. I would like this script to run every day at a certain time, 23:55 for example, as it is to get the request data open that day. Another question is...
asked by 07.03.2018 / 18:06
1
answer

Recover data from asp.net View

I have the following problem, when I place an order in the quantity field when I put a certain number I have to get it if it is in stock in the bank, and if I have to decrease the quantity in the bank, I do not know how to pass the value of the...
asked by 16.02.2018 / 20:26
3
answers

Error submitting form with ASP MVC

I'm having a problem submitting a form developed in ASP MVC. Clicking the save button returns the following error message: System.InvalidOperationException: 'Não existe item ViewData do tipo 'IEnumerable<SelectListItem>' que possui a cha...
asked by 13.02.2018 / 20:14
3
answers

How do I select the last records for specific entries?

I have a table with customer purchase records, I would like to select only the last purchase from each customer. How to do this? I tried to use DISTINCT, but I have other data I need and it is not possible to group such as date. For example:...
asked by 03.04.2018 / 19:30
1
answer

System.NullReferenceException: 'Object reference not set to an instance of an object

I was trying to run my database but this error appears. System.NullReferenceException: 'Object reference not set to an instance of an object. with era null using System; using System.Collections.Generic; using System.Configuration; usin...
asked by 07.02.2018 / 03:21
1
answer

Problems with executescalar (System.Data.SqlClient.SqlException)

I have the following code block: sqlConn.Open(); SqlCommand inserirAluno = new SqlCommand("INSERT INTO ALUNOS (Nome, DataNascimento, CPF, Endereco, Bairro, " + "CEP, Cidade, IdEstado, Sexo) OUTPUT INSERTED.ID" +...
asked by 12.03.2018 / 23:09
2
answers

Add SUM () in the querry results

I have this querry that gives me the total nr of rows that start with the same code USE CCILCDatabase; GO DECLARE @mes int; SET @mes = 1; WHILE (select @mes) <= 12 BEGIN SELECT LEFT(CONVERT(VARCHAR(10),[CPVCodeID]),2), COUNT...
asked by 02.02.2018 / 18:45
2
answers

How to export a SQL table to a .txt file?

Good morning! I need to insert the return data of a Select into a .txt file containing the column names and separating the data with ";" How can I do this? Thank you in advance     
asked by 06.02.2018 / 13:46
1
answer

Error creating foreign key

I'm creating two foreign key references pointing to two different tables, but I'm getting an error creating one.    There are no primary or candidate keys in the referenced table   'dbo.TB_PODERES' that match the referencing column list in th...
asked by 22.01.2018 / 14:39