Most voted "sql-server" questions
SQL Server is a relational database management system from Microsoft. Use this tag for all SQL Server editions, including Compact, Express, Azure, Fasttrack and PDW.
Learn more…2,752 questions
Sort by count of
-
3
votes2
answers1435
viewsSQL query taking too long and returning a Time Out error
I am trying to perform a query in SQL. Below is the method: public void excluirVenda(int Codigo) { Conexao conexao = new Conexao(); SqlCommand cmd = conexao.CreateCommand(); SqlTransaction…
-
3
votes1
answer143
viewsHow to return independent accentuation search on Asp.Net MVC systems
I have a problem in a system in relation to the search that does not return result for accentuation reasons. I would like to know how to make the accent be ignored in the system ? Note the system is…
-
3
votes4
answers3071
viewsIf condition in Where SQL Server
I have a Stored Procedure where I need to do a check for a date filter, in case the start date is null I have to do on WHERE take all records less than the final date, otherwise I make a BETWEEN…
-
3
votes1
answer43
viewsCreation of Trigger
I need to develop a Rigger in which any change that occurs in one of these fields below the Task table should send the task information to the Instruction table. TASK TABLE TarefaID Vencimento…
-
3
votes2
answers82
viewsSQLSERVER compare two groups of results
I need to make a query in sql server where I have to "connect" stocks to companies. The stock has 'n' products attached to it, and these products have 1 category linked to it. The company also has…
-
3
votes2
answers2282
viewsError with Insert in SQL Server: The Conversion of a varchar data type to a datetime data type resulted in an out-of-range value
Next I have to do a survey and implement a query in the database using Merge and I have to do it using one of the scripts used in class. The problem is that when I run the script the following error…
-
3
votes2
answers979
viewsHow to get value from a database column using C#
I have a web application that uses these 3 tables: Client: CREATE TABLE CLIENTE( ID_CLIENTE INT PRIMARY KEY, CLIENTE VARCHAR(50), ENDERECO VARCHAR(50), CIDADE VARCHAR(30), CEP VARCHAR(9), UF CHAR(2)…
-
3
votes1
answer186
viewsFormula within a Field
In a field I have the value of a formula ((B/2)+ C), where the value B and C comes from other fields, how can I exchange the values of the letters for their real values and calculate the formula? I…
-
3
votes1
answer56
viewsdoubt with date in sql tables
good, I have a table with the following information usernum / type / expiredate 1 1 2019-03-03 13:04:42.710 What I wanted to do was to have a trigger in this table that would check the date and when…
-
3
votes2
answers1257
viewsSql Server Error 8623: The query Processor Ran out of Internal Resources and could not Produce a query plan
Sql Server Database 2012 and 2008. They log the following error (sql server 2012): error_reported 2017-12-27 09:14:16.2053050 8623 16 1 False The query processor ran out of internal resources and…
-
3
votes2
answers609
viewsFor/Foreach Sql Server For Each Separate Column Data
I need to execute a command SQL to update a table, the intention of this update would be to update a column with sequential number per company, e.g.: I have a table Sale in this table have the…
-
3
votes1
answer2635
viewsSQL SERVER - RELATIONSHIP 1:N
I have two tables: books and publishers. Their relationship was defined as follows, a book may have a publishing house and a publishing house may be in several books, i.e., 1:N. I learned that the…
-
3
votes1
answer45
viewsInsert line number in SQL Manager
Hello! I’m trying to see the number of rows on the side of my SQL Manager query, but I can’t find where to put, could anyone help me? I’m getting an error in my query and it informs the line, but…
-
3
votes0
answers515
viewsWhat should I worry about when creating a Partitioned Table in SQL Server?
I was suggested to partition the main table of my system to improve the performance of some queries. The dev who made the suggestion suggested using the information from ano registry registration to…
-
3
votes1
answer100
viewsWhat precautions should I take when creating tables with 1:1 relationship?
Basically I’m in doubt about when I should use 1:1 relationship or a large table. In my case I would have the object public class Person(){ public Guid Id {get;set;} public string Name {get;set;}…
-
3
votes1
answer974
viewsSQL SERVER myth about SELECT INTO and tempdb locks
I’ve been studying a lot lately about databases and everything. Today, performing a routine check on the processes of the SQL Server instance verified that an instruction that was running in one…
-
3
votes2
answers182
viewsHigher value comparing lines
I’m using SQL Server 2008 R2 and I have the following table: ID NUMERO NOME MODELO --- ----------- ------ ------- 1 12 A 777 2 23 A 777 3 05 A 777 4 45 B 999 5 65 C 555 6 30 B 999 7 67 B 999 8 80 C…
-
3
votes1
answer580
viewsWhat is the difference between SQL Server, Mysql and other SQL?
I would like to know more clearly what are the main differences between SQL Server, PL/SQL and Mysql, and what are their main strengths/weaknesses.
-
3
votes1
answer49
viewsDoubt - Query SQL Server condition
Guys, in the query below is bringing in the following way. However, I want you to bring only the 'YES'. The difficulty is because it is a subselect with case. I bring where? No Where or a having?…
-
3
votes1
answer296
viewsHow to create an index for two tables at once in SQL Server?
I’m pretty sure there’s no way but, come on... I have the following scenario: (I included only the fundamental fields for brevity) - Tabela Venda: - id: int; - cliente_id: int; - cliente_tipo:…
-
3
votes2
answers75
viewsAdd or subtract value according to the "release type" (MSSQL)
I have the following query: SELECT MOVTIPOPRODUTO.ID_ENTIDADE, ENTIDADE.NOMECLIENTE, PRODUTO.NOMEPRODUTO, TIPOPRODUTO.DESCRICAO, MOVTIPOPRODUTO.ID_PRODUTO, MOVTIPOPRODUTO.ID_TIPOPRODUTO,…
-
3
votes1
answer154
viewsError for Importing JDBC from sqlServer with Maven
In my java web application ,I needed to add a connection to a sql server database, so I put it as a dependency on Maven as described below: <dependency>…
-
3
votes1
answer268
viewsSelect of Product Structure
Good morning! there is some way to create a query that brings the "product" and all the "Components and Subcomponents" of the structure of this product? Let me try to explain better Structure…
-
3
votes1
answer464
viewsExcel file reading with more than 1 sheet in the same file using C#
In this code I can read all the data of the spreadsheet Plan1 that has the name "Data" of the file ".xls", more if I have more spreadsheet in the same file, as I can read?. Code for reading: static…
-
3
votes1
answer283
viewsSelect Electronic Point Record (SQL)
How can I gather only the first and last appointment, where a staff member can have X Appointments and even appointments the next day? As the example below +------+--------+-------+-------+ | FUNC |…
-
3
votes3
answers680
viewsHelp with Sqlquery in context Entity Framework
I need to make a return from my database in a specific way, but I have a problem, the situation is as follows: I have this query already tested directly on SQL Server, and is working perfectly:…
-
3
votes1
answer89
viewsHow to read this JSON correctly? MSSQL and Node
{ "recordsets": [ [ { "IdUsuario": 5152490, "strNome": "Roberto ", "IdPapel": 1 }, { "IdUsuario": 5152490, "strNome": "Roberto ", "IdPapel": 3000001 } ] ] I am trying to return to the customer only…
-
3
votes1
answer679
viewsRows in Columns without Column Preset - SQL Server
Hello, I’m having a hard time turning rows into columns on SQL Server. I haven’t been able to write anything yet... I thought about PIVOT, but since it’s not always the same amount of columns, I’m…
sql-serverasked 5 years, 10 months ago LeoHenrique 954 -
3
votes1
answer50
viewsError adding Controler to ASP.NET MVC
A doubt when creating a controller. Because when trying to create it has shown the error of the attached image. I created 3 small classes: Dependentes, Tipobenef, TitularPlano and ProvaContext…
-
3
votes3
answers1854
viewsSQL query to know the sales of a period (year), dividing by month and showing the total of each month and year
I work as a technical support in an automation system, a customer asked if there was a report in the system that showed the total sales of 2018 divided by month and showing the total of each month…
-
3
votes1
answer241
viewsSQL Server - Monthly period comparison
Hi, guys. I have a big question. I have two banks (Mysql) where I accumulate sales of several stores and use a third bank where I do an ETL using the data union. In my third database (SQL Server) I…
sql-serverasked 5 years, 9 months ago Vitor Tenório 57 -
3
votes2
answers171
viewsSelect within select where condition exists
Good morning, With a table of articles with the fields Reference | Quantity | Price | Referencesociated | I wanted to have a select that would do the following, with the example: Example Table of…
-
3
votes1
answer725
viewsLogic SELECT CASE WHEN
would like help in building the following logic: I have my main table and two other tables A and B, which have foreign key from the main. When an X column is filled in table A I need to classify my…
-
3
votes1
answer653
viewsIs it possible to make a direct SPLIT in a QUERY (SELECT) in SQL SERVER 2012?
I have the following table below and I need to divide the "Full Name" column into columns in the same SELECT where each column should be filled according to its level. Ex: The Full Name column…
-
3
votes1
answer251
viewsError running Entity Framework
I am starting my studies in EF, following this tutorial, I made up to 22 min of the video, then when I will run: System.Typeinitializationexception: 'The 'System.Data.Entity.Internal.Appconfig' type…
-
3
votes0
answers959
viewsProblem saving date with Time Zone (Time Zone) in SQL Server
I need my system to store dates (date and time) with time zone (time zone). The system needs to support multiple databases, so far SQL Server and Postgresql. With Postgresql the time zone…
-
3
votes2
answers134
viewsEF Core - Pass parameter with integer list
I am trying to execute a query by passing as clause an 'in' with integers, this is the code so far: public List<Pedido> GetByUsuario(List<GestorVendedor> gestorVendedor) { int[]…
-
3
votes2
answers145
viewscheckar checkbox of gridview based on database value
My application needs to release types of accesses, for example, we have 5 branches and such person needs to access content from only 3 branches. The ADM user, can create or edit new users. When…
-
3
votes1
answer47
viewsHow to concatenate columns identified by surname?
I have the following appointment: select case when datediff(...) > 0 then month(tblData.data1) when day(tblData.data2) > 10 then month(tblData.data2) when month(tblData.data2) = 1 then 12 else…
-
3
votes1
answer23
viewsHow to count records in the Onetomane relation returning zero when there is no match
Friends, I am trying to make an app to control investments in shares. In DB of this app I have the table portfolio and active table. I need to make a select that returns to me the active portfolios…
-
3
votes2
answers475
viewsConnection error with SQL Server 2012 with Python
I am trying to connect to SQL Server 2012 using Python 3.7 and Ubuntu 20.04.1 LTS as follows: import pyodbc server = 'tcp:192.168.0.7, 1433' database = 'teste' username = 'teste' password = 'teste'…
-
3
votes1
answer52
viewsHow to make a LIKE IN equivalent to PROCV
I have the following question (below is just an example, because I can not send the true info) I want to make a where where I find the name of the social reason by the fancy name of the…
-
3
votes1
answer61
viewsDate sum with condition?
I have a base with the 3 columns and one that I created. ╔═══════════════════════════╦═════════════════════╦════════════════════════╦═══════════╗ ║ DATA ║ LATITU ║ LONGIT ║ ROW ║…
sql-serverasked 3 years, 9 months ago Carlos Gabriel 41 -
2
votes2
answers1011
viewsHow to open a report file in RDF format?
They sent me a report with the extension .rdf. The system that generated this report uses MS SQL server 2008 as DBMS. I would like to know how to view and manipulate the information in this file.…
-
2
votes1
answer1352
viewsError: subquery returning more than one result
Given the sql: DELETE FROM wgcartarmazens WHERE ( SELECT artigo FROM wgcartarmazens as T INNER JOIN wgcartigos as A ON A.CODIGO=T.ARTIGO WHERE T.lote='' AND A.TEMLOTE<>0 ); The above query…
-
2
votes1
answer1249
viewsASP MVC 4 and Webservice
I have a Webservice with all the methods I need to make the system work and I also have a page ASP NET MVC 4. I already referenced the Webservice Referral Service. I can access a method that returns…
c# asp.net-mvc sql-server web-service visual-studio-2013asked 10 years, 7 months ago Thiago Alex 349 -
2
votes1
answer593
viewsHow to use LEAD and LAG using a condition
My question is, if I can use LAG and LEAD, using a condition in the query, for example: I have the spine cep.. I want to take the value of the next row, and the value of the previous row of that…
-
2
votes2
answers282
viewsError while trying to connect to database
I’m studying about C# and Asp.net and "trying" to draft a registration, amendment and exclusion project, following some videos lessons I found on the net. The problem is when I connect the database…
-
2
votes2
answers4968
viewsError initializing SQL Server Express
I try to initialize the SQL Server service (SQLEXPRESS) and I get this error message: What can it be?
-
2
votes2
answers2389
viewsStored Procedure with output parameter being the Id of the last insertion. C#
Hello, I’m performing an insert in a table, but I need it to return the ID you just entered. I searched on the command OUTPUT but I couldn’t solve my problem. I need to do all this using procedures,…