Questions tagged as 'sql-server'

2
answers

Difference of hours query sql server

I have the following data: 2016-10-13 09:04:00.000 1 2016-10-13 20:33:00.000 4 2016-10-14 09:10:00.000 1 2016-10-14 21:04:00.000 4 2016-10-17 09:04:00.000 1 2016-10-17 19:50:00.000 4 How to tell the difference between hours between 4...
asked by 18.10.2016 / 16:38
1
answer

Import data from excel to sql server

I need to import the data that is in excel to a table in sql. I looked at several sites but nothing so far has worked out. Using sql server management studio I have done the following so far, following the step a step : sp_configure 'show adv...
asked by 26.08.2014 / 17:09
2
answers

Error: Can not find data type long

I'm trying to create a procedure in SQL Server 2012, but it's giving the following error in signing it. Mensagem 2715, Nível 16, Estado 3, Procedimento MINHAPROCEDURE, Linha 6 Column, parameter, or variable #1: Cannot find data type long. Para...
asked by 27.09.2015 / 17:24
3
answers

How to avoid calculation error in SQL Server?

I have a query that makes a calculation, plus the field "a.costarticles" appears with value zero at times, then it generates a division error by zero, is it possible to pass some default value? Type 1 if it has a value of zero? select a.totalc...
asked by 30.09.2015 / 14:40
3
answers

Help with SqlQuery in context Entity Framework

I need to make a return of my database in a specific way, however I have a problem, the situation is as follows: I have this query already tested directly on SQL Server , and it is working perfectly: SELECT COUNT (ate.id) AS data,...
asked by 13.11.2018 / 16:28
2
answers

doubts with query in sql

I have a table with 5 fields: id name charge salary data ... and I wanted to make a query that would return the names of the people with the highest salary, of each position, for example I have 3 positions: analyst, dev and engine...
asked by 21.07.2017 / 13:19
2
answers

SQL Query - CASE with LEFT JOIN

I need to create a query that returns all active students and their grades for each subject. If the student does not have a grade for a given subject, the student must return the subject and note the value "No grade". I think I'll need to cre...
asked by 20.05.2017 / 23:38
1
answer

View with parameters without external?

I need to get parameters for a view , but since it has COUNT(DISTINCT DTA_HOR) I can not get the where external. Would it have any other way? SELECT EX1 ,EX2, EX3, EX4, (SELECT COUNT(DISTINCT DTA_HOR) FROM TB_1 WH...
asked by 25.05.2017 / 23:21
2
answers

Masking SQL Select Return

I'm using the following SELECT to return the IDs of a table. SELECT id, duracao_sessao FROM usuario For ID 1 I want the text "Object" to be displayed For ID 2 I want the text "Class" to be displayed For ID 3, I want the text "Struc...
asked by 02.12.2017 / 19:06
1
answer

SQL Select highest value item

I'm using the NorthWind database, and I want to select the category that has the largest number of items entered. I was able to list the category ID and the number of products it has with the following command: SELECT CategoryID, COUNT(Product...
asked by 26.11.2017 / 20:23