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
votes0
answers38
viewsHow can I clone a record from a stored table using Procedure and picking up the fields dynamically?
I have the need to clone a record into a table but picking up the fields the way they are, the reason is that someone can insert or remove some column, so I don’t know which columns I have in the…
-
0
votes0
answers504
viewsBULK INSERT in SQL Server with variable columns in CSV
Hello. I get *.CSV files from a program that measures ink tint. If the ink is solid I get a file with 15 items (spetrum at 45°angle), if it is metallic with 36 items (Spectrum at 25°, 45°, and…
-
0
votes1
answer45
viewsHow can I use sp_executesql to execute a query mounted on a variable?
I’m learning to use cursors and I’m trying to run a query I’ve mounted within a variable but it’s giving the following error: "Message 214, Level 16, Status 2, Procedure sp_executesql, Line 1…
-
0
votes0
answers224
viewsHow do I make an Insert into using dynamic SQL and run sp_executesql?
I am trying to make an Insert using cursor and execute sp_executesql using variable, the first time it ran and did not return anything, I went to the table and had not added any record. Then I ran…
-
0
votes1
answer30
viewsHow do I get back the id of the new record created in a table using cursor and Procedure in SQL Server?
I’m trying to make my previous run and return the registration ID that has just been created, as I don’t have much knowledge of cursors and procedures I don’t know where I am failing. When I run the…
-
0
votes1
answer145
viewsKNEX: How to create an array from the result of the query in Sqlserver?
I am using the Knex to make a query that united several tables from a bank Sqlserver (use two version of Sqlserver 9.0.3042 and 12.0.5000.0), example: knex('tabelaA') .join('tabelaB',…
-
0
votes1
answer401
viewsHow to calculate value + sum(value) within a select
Hello I plan to make a select in that direction: select NUM_PEDIDO, VALOR, ((VALOR/ sum(VALOR)) * 100) as PORC from PEDIDO Obviously this will return me this error: (... is invalid in the select…
-
0
votes1
answer440
viewsCan I work with array in SQL SERVER?
Hello fellow collaborators... I have a server that has more than 100 banks, and most are of the same structure. I would like to create a function, process or whatever. That could expedite my…
-
0
votes1
answer48
viewsHow to look at the field that is being changed in a Procedure?
I created a precedent where after running or updating in a table the flag is marked S automatically, causing this item to go up to an integration and integration after the return of success mark the…
-
0
votes2
answers147
viewsLoop - SQL Server
good afternoon. All right? I’m trying to print a loop of hours where Data10 should show start date + 10 seconds and Data5 should show start date + 5 minutes I tried the down loop without success:…
-
0
votes1
answer68
viewsTranscribing from Mysql to SQL
How does this Mysql code look in SQL (in Dbeaver with Azure connection)? I just need to change SELECT to work in SQL CREATION OF TABLES -- VACANCY TABLE create table vagas ( idSensor int primary…
-
0
votes1
answer47
viewsHow to convert UNIQUEIDENTIFIER to INT?
So quiet people? I’m beginner with SQL SERVER and I’m in a situation where I don’t know how to proceed anymore. I have 2 banks on a server here at the company, and I need to replicate some data that…
-
0
votes1
answer49
viewsOrdination Plan of Accounts
Currently this ordained 3.1 3.10 3.11 3.2 3.3 3.4 ... 3.9 and should stay: 3.1 3.2 3.3 3.4 ... 3.9 3.10 3.11 script: SELECT GCD_Tid, GCD_Ordem, GCD_Nome, GCD_GCD_TidGrupoContasDre, [1], [2], [3],…
sql-serverasked 4 years, 3 months ago Eduardo Nogueira 1 -
0
votes2
answers790
viewsHow to get max() and min() data in SQL?
How can I get the minimum and maximum date of a table? I am using the functions min() and max(), but it is not returning the expected value. This is a small example of the date data from my table:…
-
0
votes1
answer63
viewsSelect SQL SERVER PDO data for a select list with PHP
Dear ones, I have designed this code snippet so that the data received from my SQL SERVER database is listed in a select via PDO: consultationphp.: <form name="cargo" method="post"…
-
0
votes0
answers70
viewsHow to optimize access to the Database?
I’m doing a project where I often need to access the database to do things like: Load User Data (Example: Balance, Settings); Upload images; Insert/Update data. It’s a pretty boring process to have…
-
0
votes1
answer51
viewsQuery of two values for a Column
It has a table named Preco. Inside this table if you find the sale price and the cost of the product however, I cannot print in echo pq the name of the column is one and does not specify who is sale…
-
0
votes1
answer69
viewsFind a best-selling item along with another
Find a best-selling item along with another. Sql server TABLE SALE CAMPOS = ttcupomfiscalitem PRODUCT TABLE FIELDS = ( tcproducts) I tried to make the following sqlserver query SELECT TOP (10)…
-
0
votes0
answers27
viewsHow to create a Not Null field with an index associated with Nhibernate Fluent
I have a problem creating a field when using Fluent Nhibernate with SQL Server (C#): I have this entity with some fields with primitive types and others are complex fields: public class…
-
0
votes0
answers27
viewsCreating a VIEW of a VIEW
I have the following problem in the company, where I have several panels that get information from a VIEW that does not have NOLOCK in the query. In order not to have to change each panel, it would…
-
0
votes0
answers23
viewsConsultation of Total General
I am with the need to build a query where I have the following situation Table 1- Sales [1]: https://i.stack.imgur.com/6GOO7.png In this table I have other vendor codes with other values. I am…
-
0
votes2
answers33
viewsSelect in 3 tables returning multiple Oids
Script only works by returning a single codpro (4609), needed it to return several SELECT a.filial, a.codpro, b.descricaolonga , a.quant, a.estminimo, c.filial AS 'filial ped', c.quant AS…
-
0
votes1
answer108
viewsRefer to employees with equal names and different Cpfs
Problem: I need to consult employees who have equal names but with different CPF. Below is an example of the structure of the table create table #tmp (nome varchar(255), cpf varchar(255)) insert…
sql-serverasked 4 years, 1 month ago LucasTiago 13 -
0
votes1
answer45
viewsIs it possible to make an addition with varchar field?
I have the following update: update ex set ex.seq_docum_ref = '00001', ex.nr_chv_nfe_ref = ref.ChaveNfTerceiro, ex.cd_docum_ref = case when ChaveNfTerceiro is not null then…
sql-serverasked 4 years, 1 month ago Renan Goulart 11 -
0
votes1
answer205
viewsSQLCMD does not execute command after silent installation of SQL Server with Inno Setup
I have a script from Inno Setup which provides the user with the installation of SQL Server 2012, and upon completion, he should restore a database in a specified path, in order to 'componentize' my…
-
0
votes0
answers113
viewsQuery in a SQL SERVER table
Hello, people. I need to make a query in SQL SERVER but the same is returning incorrect values. I have the following tables. In the proposed exercise I must return the following information: Extract…
-
0
votes1
answer65
viewsCursor search: the number of variables declared in the INTO list must match the number of columns selected
Hello! I made a T-SQL and at the moment execute is giving the message: Message 16924, Level 16, State 1, Line 58 Cursor search: the number of variables declared in the INTO list must match the…
-
0
votes3
answers1117
viewsTCP/IP connection failure when trying to connect to an SQL Server database
The code I made was a basic Microsoft example of how to make the connection. The driver is already installed. package connection; import javax.swing.*; import java.sql.*; import…
-
0
votes1
answer31
viewsHelp with SQL query - delete a field/ occurrence
I am trying to perform a query where all beings should be managers but they should not have worked on a project. It turns out that this john is the only being who works and manages a project and I…
-
0
votes1
answer44
viewsDoubts about if clause
I have a problem in the query below: THERE ARE SOME DATA THAT ARE ON D1_NFORI, THAT MISSING "0" THE LEFT WOULD NEED TO INCLUDE THE ZEROS TO COMPARE IN THE WHERE EXAMPLE: Where IF D1_NFORI NOT LIKE…
-
0
votes0
answers140
viewsCall to a Member Function result() on bool
I’m trying to get results from a Stored Procedure in the CodeIgniter, in the bank brings the result normally but in the CodeIgniter brings that mistake: in my model is like this: public function…
-
0
votes1
answer279
viewsSql Server - Time Conversion (HH:mm) to Decimal
Hello, I am working on a system that requires conversion of hours to decimal and is showing error conversion from HOUR (HH:mm) to decimal when total hours exceeds 23:59. For better understanding if…
-
0
votes0
answers68
viewsHow to compare SUM with another numeric field?
Good afternoon, I have a table SB2010 where I have the current quantity of product in stock and have the table SB8010 where I have the quantity of the product separated by lots. I need to verify if…
-
0
votes1
answer233
viewsQuery user in Sql server
As I do to return instead of a query through a fixed user, the code was in the database to query the users and return it. I use Sql Server with aspnet core 3.1 application Someone who can help me in…
-
0
votes1
answer79
viewsProblems with Insert SQL Server
I am looking for a solution to solve my problem. When I ask for 2 items of the same type on my site it inserts 2 times the same item. I already tried to create a TRIGGER with AFTER INSERT to check…
sql-serverasked 4 years ago Mercurio 1 -
0
votes1
answer36
viewsSQL - doubt in query
I have the following appointment to do, I was able to think of them separately. I’m starting to study databases and I don’t know how to relate the two. Table Occurrence number, date, description,…
-
0
votes1
answer1304
viewspyodbc.Interfaceerror: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Name of data source not found
I am creating a code to perform an adjustment in a sql server database, but when trying to run it is returning error: pyodbc.Interfaceerror: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Name…
-
0
votes2
answers93
viewsHow do I get as much and as little as possible of a consult?
I have the following consultation: select DATEDIFF("D",DtVencimento,DtBaixa) as atraso from Entrada where Id='1' and DtEmissao >='01/01/2020' and DtEmissao <='01/12/2020' and ((VlBaixado is…
-
0
votes0
answers24
viewsUnilateral Relationship EF sql Server
I have a problem in the relationship of entities with the Entity Framework Core v3.1.5, Code First I have entity Cliente relating to the entity DadosProfissional and my problem is, when I register a…
sql-server asp.net-core asp.net-web-api entity-framework-coreasked 3 years, 11 months ago Ricardo Soares 29 -
0
votes1
answer35
viewsRegistration game with Postman
Hello, I’m trying to make a registration of a game but when I try to run by Postman it does not work and says that everything is null Code [HttpPost] public async Task<IActionResult>…
-
0
votes1
answer69
viewsView SQL database data in a similar way to the Access database
Good afternoon gentlemen I am a layman in the subject of SQL database and I am trying to visualize the data of an SQL database in table form, below is the name database E3 already created being…
-
0
votes2
answers63
viewsHow to select CNPJ higher billing? - SQL -
Hello, everybody! I have a table of customers with Grupo Economico code and CNPJ, each economic group has more than one record, and I cross-checked with my Billing and Address table, so far so good.…
-
0
votes1
answer17
viewsHow to Create XML Array in SQL
I have the following XML structure <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:gen="http://www.rapidaocometa.com.br/GenPoWMS10In"…
-
0
votes2
answers54
viewsQuery duplicate numeric field in sql server
Good morning! I have a table of notes and in the month of December there was a duplicity of several notes. These duplicated notes have different numbers, however, the total value of the note is…
-
0
votes1
answer87
viewsC# and MS SQL Server Special Characters
I have a table of municipalities within the system, MS SQL Server database, and the names of municipalities are accented. I am consuming an API where municipalities come without any accentuation, so…
-
0
votes0
answers17
viewsHow do I handle non-existent data in the SQL Server table
For example, I need to bring data from a table in a certain date period into sql considering the data that does not exist in the table. EX: SUM(CampoValor) AS 'VALOR', COUNT(*) AS 'QTD' FROM TABELA…
sql-serverasked 3 years, 10 months ago Carllos_Dc 1 -
0
votes0
answers28
viewsError connecting to SQL Server with ADO
I am trying to make a connection to a database in Sql Server, so it is giving this error Javascript Runtime error. [Microsoft][ODBC Driver Manager] Data source name not found and no default driver…
-
0
votes0
answers29
viewsImport Simple File by SQL Server Magement Studio giving Expired Run Time Out error
Hello. I am using the "Import Simple File" wizard from SQL Server Magement Studio to import a 2GB TXT file into a SQL Server Express database. I follow the entire process of the wizard, it…
-
0
votes0
answers14
viewsSqlserver to Mysql conversion - sys table id
I have the following query in SQL Server: Declare @val Varchar(max) Select @val = COALESCE(@val + ', ' + col.name, col.name) FROM sys.objects AS obj INNER JOIN sys.columns AS col ON col.object_id =…
-
0
votes0
answers27
viewsError installing SQL server - Linux Mint
I already have flask installed on my NOTEBOOK with Linux Mint, but still no module called flask is showing up along with dpkg error. I tried various solutions on various websites such as: sudo dpkg…