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
-
0
votes1
answer98
viewsSELECT SQL Server VB NET error
Using con As SqlConnection = getconnectionSQL() Try con.Open() Dim cmd As New SqlCommand("SELECT * From Diaria where data='" & data_SQL(TextBox4.Text) & "' and prefixo='" &…
-
0
votes1
answer85
viewsHow to make a select if repeat integer 1 time for each month in a dynamic date range?
Assuming I have sales that happened in the month of May. I could make the following select: SELECT * FROM Vendas WHERE MONTH(Data_Venda) = 5 Assuming the month of June happened and now I have sales…
-
0
votes1
answer221
viewsHow to call a c# function when an SQL Server table changes
I have the following code on C# Asp.NET 4.5 to count the number of records in my table [HttpGet] [Route("consult")] public HttpResponseMessage GetAll() { try { MatrizGeneral matriz = null; //int…
-
0
votes1
answer121
viewsColumn with utf-8 character error
When executing: SELECT campus_nome FROM cursosprounine where campus_nome like ('%?%')group by campus_nome; to check the character error, I found a code that taught me to convert the column: UPDATE…
-
0
votes1
answer32
viewsGroup By com sql server
I am trying to group the data of my select , according to the field C9_CARGA , however when I run this select it returns me without being grouped , I believe I am doing something wrong . How are you…
-
0
votes1
answer91
viewsSqlserver: How to detect consecutive days in a table
I need to insert into a time table only the rows of another table in which the Membershipdate column has 1 day difference dates. For example, in the table image below, only lines 1, 2 and 3 would go…
-
0
votes2
answers41
viewsChange the value of a field when a condition is true
Good evening, everyone, Can you help me? I need to create a view with the data below, however I need to create a condition where when the value of MC.SITUACAO is equal to 'A', the fields…
-
0
votes1
answer124
viewsQuery to bring 1 parent record and in it can contain multiple children records (performance)
Supposing for the client I can add more joins as not only sales, and the result of this consultation bring much more records. This is a performative way of working or would be better to query each…
-
0
votes0
answers546
viewsSQL tables for postal codes
Good, I am creating a BD for a project I am doing and in this project are included Addresses (Customers, Suppliers, etc.), addresses that will contain Postal Code. My question is this:: I have 3…
-
0
votes1
answer1228
viewsHow to send values with Zeros to left SQL SERVER
When trying to send values with zero on the left, when checking in the database I receive the values in zeros. Ex: 000431, appears in the database as 431. This value is being placed in the $prefix…
-
0
votes1
answer79
viewscompare Sql data with two Foreach
I’m looking for data from two tables which have an equal column, which is called the prefix column. I tried to mount a foreach inside the other foreach with the data of the two tables and comparing…
-
0
votes4
answers114
viewsDoubt QUERY SQL construction
I have two TB1 and TB2 tables with equal fields in order to compare the records. The logic is: Query the records contained in TB1, but not contained TB2, considering 3 fields: code, date and value.…
-
0
votes2
answers55
viewsHow to make a codition inside a NOT IN on Sqlserver
Suppose I have the following data, license plates, category, and situation: 1- 1 - Encerrado 2- 10 - Concluído 3- 11 - Pendente 5 - 2 - Encerrado 6 - 1 - Pendente 9- 10- Encerrado And I want to do a…
-
0
votes1
answer150
viewsGet line data after button click on an ASP.NET Repeater
Good evening, my question is this... I want to make a "select" of the data of a line of the Repeater control according to the clicked Linkbutton (the white pencil of blue background), thus storing…
-
0
votes2
answers413
viewsSQL Server - calculate number of word occurrences in a column, per record
My goal is to create a select to return the total occurrences of a word, a column, per record My table is modeled as follows: id / filename / qntd_pg / content ex: I want to search how many times…
-
0
votes1
answer1200
viewsA server connection was successfully established, but an error occurred during the logon process
Hello guys I’m having a problem trying to make the connection to a database via Microsoft SQL Server Management Studio but it displays the following error message: A server connection was…
-
0
votes0
answers48
viewsDoubt for database structuring - SQL Server
Good night! I would like to ask for help to have some ideas, I will explain more or less what I would like: Let’s say I have two databases, one to serve as Central (receives information from various…
-
0
votes1
answer786
viewsHow to join these two selects of the same table in SQL server?
Next, I need the amount per month of each customer who entered the year managed to do this, however I want q be shown in only 1 result. How do I join the two SELECTS? In order that it is added to…
-
0
votes1
answer456
viewsCreate dynamic table of the result of an exec return with Sql server variable
Good morning, I’m having difficulty to do in sql server 2014. I need the result back exec (@query) create a dynamic table with this result filling in with columns and rows. Query I’m using to mount:…
-
0
votes1
answer78
viewsSQL gets Double with "Comma" tab instead of "Dot"
I am developing an ASP.NET application where I need to take a DOBULE typed by the user and pass to the bank. However there is a divergence of information, the DOUBLE of my bank receives separator…
-
0
votes1
answer96
viewsDjango connection to sql express 2017
My python version is : 3.7.5 my Django version is : 3.0.2 when I ran the command 'Pip install Django-pyodbc-Azure' it uninstalled my Django version and installed version 2.1 In the file of Settings…
-
0
votes1
answer557
viewsCase in Where for query filter
I have this select below, but when date is true, he needs to bring all the records where the field OrdemServicos.DataConclusao is different from null, and when it is false needs to bring everyone…
-
0
votes1
answer182
views'System.Data.Sqlclient.Sqlconnection' does not contain a Definition for 'Query'
I wrote a C# method to make a "switch" between different database types in my application. Where the problem is that each database type makes use of a different library (SQL => Sqlconnection and…
-
0
votes1
answer28
viewshow to use the SELECT statement to be inserted in a column in the same table?
SELECT Names,SUBSTRING(Names,10,50) AS Alias FROM NameToSplit; Here I do not want to put the Aliases, but INSERT in the column Alias this Select statement. then I need to take this column Alias and…
-
0
votes1
answer158
viewsSwap subselect with Oin
good morning! I’m sorry if explanation is not totally clear, it’s because I’m starting in SQL. How do I replace subselect with some type of Join? Because subselect takes longer to load. Examples:…
-
0
votes0
answers71
viewsRead an image in SQL Server for a picturebox in C#
I have Bytearrays of images in a database on Mysql Server and I intend to read them and after that convert Bytearray to an image that can be arranged in a picturebox. I have tried using other…
-
0
votes0
answers123
viewsIs ROWCOUNT reliable for change checking?
I am mounting a query to be executed via DAPPER/C#, my idea is not to check if the data exists in the table returning the object to the application, but rather, to check directly in the data bank of…
sql-server performance sql-update software-architectureasked 4 years, 9 months ago Marco Souza 12,304 -
0
votes1
answer215
viewsHow to recur SQL server using WITH to return all children
I am trying to make a recursive in a single table called local where there is a localSuperior ID, referencing the same table. If I have my biggest place with ID 1664, when making the recursive, it…
-
0
votes1
answer28
viewsDoubt in the use of Dateformat in linked server (Linked)
I have the following situation. Executing that script: SELECT CONVERT(DATETIME, CONVERT(VARCHAR, 12) + '/' + CONVERT(VARCHAR, 31) + '/' + CONVERT(VARCHAR, 1900) + ' ' + CONVERT(VARCHAR, 0) + ':' +…
-
0
votes2
answers235
viewsHow to convert MM/dd/yyyy to dd/MM/yyyy?
I think because my computer is from the USA it always saves the dates in American format, anyway, I have a Date Time Picker that on the client’s computer is in Brazilian format, but when he saves…
-
0
votes1
answer307
viewsCreate a Trigger with JOINS
Good afternoon, everyone, I have two tables: SELECT [CodigoProduto] ,[CodigoDistribuidor] ,[Produto] ,[ProdutoLimpo] ,[NomeMarca] ,[StatusProduto] ,[ChaveProduto] FROM [dbo].[Produto] GO SELECT…
-
0
votes0
answers21
viewsDoubt about setting size for table fields!
Hello! Follow the following code: create table Pessoa ( codigo_pessoa int not null primary key, nome nvarchar(50) not null, data_nascimento date not null, cpf int(11) not null ) In the field of Cpf,…
sql-serverasked 4 years, 8 months ago STR21 19 -
0
votes1
answer41
viewsStore Procedure with SELECT and with data make an INSERT
Good morning I need to do a Store Procedure where I need to do an Insert but I need to pull data from another table to include this Insert. Example: '''CREATE PROCEDURE…
sql-serverasked 4 years, 8 months ago João Bosco 41 -
0
votes2
answers865
viewsCalculate total amount and total SQL Server value with three tables
Sds, I have a problem, I am not able to group the municipalities in my SELECT. Even with the group by the municipalities are separated. There are three different tables, municipality, product and…
-
0
votes1
answer148
viewsError while trying to create new field in a model in Django
When trying to create a new field in a model while creating an api, I get the following error when running the command runserver: That would be the class: class Person(models.Model): teste =…
-
0
votes0
answers96
viewsThe column '<column name>' is invalid in the selection list because it is not contained in an aggregation function or in the GROUP BY clause
Hello! In the system there is data collection for some questions and the answers are 0-100. My database has the following tables: Person, Question, Personal. I’m trying to get a select where to…
-
0
votes0
answers47
viewsPROCEDURE WITH MEDIUM
Good morning, everyone, I have the following tables: Create table FUNCIONARIOS (num number, nome varchar2(30), custo_hora number); Create table PROJETOS (cod number, nome varchar2(15), custo_acc…
-
0
votes0
answers83
viewsHow to identify left and right table in the execution of multiple Joins in SQL?
I’m trying to understand how to read the execution of multiple INNER Joins. If I do multiple INNER Joins my left table remains the same as the first INNER JOIN or the left table becomes the…
-
0
votes1
answer95
viewsI need to update the value of one SQL table with the sum of the values of another
I need to update the value of the column total_services of a certain number with the value (value value value * quantity) of the table nfpse_detail The command I’m using to try to do this is this…
-
0
votes1
answer273
viewsCreate temporary table from cursor data
I created a cursor that shows the date of sale and the total sold value of the day. Follow the code: declare cursorteste cursor local forward_only for select data_venda, sum(valor_unitario) as…
-
0
votes1
answer41
viewsValidate parameter to disregard left Join
I’m setting up a select, but depending on the value of a come parameter (store = 00000 - all stores), I’d like to skip the "AND p.store = e.store " section on the left Join so that it disregards the…
-
0
votes5
answers97
viewsDoubt with Select using ORDER BY
I’m trying to make a SELECT so that it displays from the second table only the most recent record. I tried to do it using GROUP BY and ORDER BY, but with the GROUP BY mine SELECT does not work, only…
-
0
votes1
answer39
viewsInserting data with a proc in SQL Server
I need to use a procedure that adds data to the table Pedido and then on the table ItemPedido automatically. But I’m not able to create a Procedure work. Follow my code below: create procedure…
-
0
votes1
answer39
viewsPlot Pivot (Row in column)
Gentlemen, good morning ! I am trying to make a simple parcel PIVOT under same customer number (330162210001), however I am not getting... The idea is that each plot result found is a column. We…
-
0
votes1
answer62
viewsError searching for record with Firstordefaultasync ASP . NET CORE 3.0
I have a method to search the client in the database by the number of the CPF (no points, only the numbers), but in the database the type is as VARCHAR. I did some tests by POSTMAN to test the API…
-
0
votes1
answer449
viewsHow to run an INSERT Procedure with the GETDATE field? SQL Server
Next, I created a precedent that has two parameters Dt_inclusion and Dt_alteration, I would like to know how to insert(or if it is possible to use) a getdate to pick up the current date, instead of…
-
0
votes2
answers52
viewsI cannot insert in sqlServer table float data when they are greater than 1000
I am not able to insert double variables when they are greater than 1,000.00 because of the comma that Apare and so sql recognizes that I am trying to insert two data, I tried to use the…
-
0
votes1
answer816
viewsCreate SQL SERVER database
Good afternoon to all! :) I’m new to programming and I’m having some difficulties I am trying to create a precedent to update the Cli_totalcompras column, with the total amount already spent by the…
-
0
votes3
answers47
viewsSql return generation limit
I have this code, which generates number of periods, but I take this return to excel, I can define the amount of returns? I could only bring five, returns, I can limit? DECLARE @serie INT, @ordem…
-
0
votes1
answer41
viewsSQL Server Order Allocation
It is possible for me to relocate this latest product with ID 21, to the field I have drawn in red? Actually, look at that. It is not by TOC, but something functional, in our site where it is taking…