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
-
1
votes1
answer212
viewsT-SQL - Delete filter "NOT IN" does not work
I am filtering my base by store code (varchar), but the filter is not removing the store codes I want to delete from my query. This is my consultation: SELECT A.CPF , A.[Cod Loja] , B.NomeLoja ,…
-
1
votes1
answer79
viewsRemove numbers before the comma
I have a numeric sequence in string type '0,1;2,2;5,3;8,4;'. I need the results to come out '1,2,3,4' only the numbers after the comma. I’ve tried the following consultation: {select…
-
1
votes1
answer42
viewsIs there the possibility of data loss while converting text data types to nvarchar(max)?
I have a legacy database in production with data stored with the type text but there was a need to convert them to nvarchar(max) and by chance I saw that this was already a recommendation from…
-
1
votes1
answer375
viewsHow to return the total amount when using OFFSET and FETCH NEXT?
I had to use OFFSET and FETCH NEXT to return a data range between my query. Table CREATE TABLE [dbo].[Usuario] ( [Id] [int] IDENTITY(1,1) NOT NULL, [Email] [nvarchar](max) NULL, [Nome]…
-
1
votes2
answers458
viewsSum in a Pivot Table
I’m learning how to use tables with PIVOT in Sql-Server. I have a table with the item name, seller name and customer id. Item | Customer | ID Rep Pen Set | 1001 | Richard Binder | 25092 | Nick Pen…
-
1
votes2
answers169
viewsHow to Make a Scan in SQL
| cliente | id | cpf | cpf_valido 2 | 1234 | 1 3 | 1234 | 1 5 | 4567 | 0 and I need to set up the table like this | de_para | id | id_para | cpf 2 | 3 |1234 3 | 3 |1234 5 | 5 |4567 To summarize,…
-
1
votes1
answer80
viewsHow to update via Linked server without using Join / relationship?
I need to use data from more than one table in the same select without having to JOIN / relationship (I want to set a value from one table to another through a Linked server). I tried the following…
-
1
votes1
answer660
viewsHow to sort a date that is in varchar format?
I have the following select: SELECT a.nome, a.cidade, a.telefone, a.dt_criado FROM cadastro AS a GROUP BY a.nome, a.cidade, a.telefone, a.dt_criado HAVING COUNT(*) > 0 ORDER BY a.dt_criado DESC…
-
1
votes2
answers95
viewsSubconsulta with MIN AND MAX together
How can I bring a column along with min() and max().... this is possible ? select Name, Size from Production.Product Where Size in (select MIN(Size), MAX(Size) from Production.Product)…
-
1
votes1
answer78
viewsHow to select only 1 record per month with SQL
I have a sales chart and would like to select customers' sales, but if the customer made more than one sale per month, I would like you to bring the oldest just, how could I do that? I don’t have an…
-
1
votes2
answers326
viewsError when trying to connect to SQL Server with Codeigniter and PHP 7
Good afternoon, I started having problems with my CI when updating my development environment (windows + xammp) and production (Ubuntu + apache) to the latest version of PHP 7.1.10. When trying to…
-
1
votes2
answers50
viewsSelect only 1 record per month with an aggravating factor that prevents the use of Group By
I have the following table: I need to bring only the oldest customer sale, regardless of the type of sale, however I need the sale guy to come on select, before I had a similar doubt and helped me…
-
1
votes1
answer216
viewsDDD + Entityframework + Migrations + SQL Server
Hello, I have a Solution that I am implementing the DDD architecture with Entityframework, Migrations and SQL Server! However I am not able to connect to my local database when performing the…
-
1
votes0
answers10
viewsConvert SQL to Mongodb
--Personal Peco helps to convert the following sql query to mongodb: select count(*) FROM tabela Where ((DataFim - DataInicio ) /1000 /60 /60) is not null and ((DataFim - DataInicio ) /1000 /60 /60)…
-
1
votes0
answers44
viewsSql Server Function - 0 hours today to the current time
Please select the amount of hours in regression until 00:00 hours in Sql Server, always of the current day. I get this through a function like 'DATEADD'? Ex: Now it is 15:00 hrs would like to pick…
-
1
votes2
answers425
viewsI need to relate two tables in order to bring me a result within the conditions I want
I’m using the SQLSERVER Condition(What the result should return to me) Creation of the agenda. Necessary creation of the flow for creation of agenda and blocking to reserve the vacancies; When…
-
1
votes1
answer35
viewsQuery to list the amount(Count) of records for a Foreign key
I’m trying to create a query that lists how many times a Foreign key has appeared from another table but I’m not getting it. I wanted to count how many times each customer appears in the order,…
-
1
votes4
answers949
viewsDay and month comparison on SQL Server
I need to filter a query of every client who has a birthday between two informed dates. How can I make a comparison of dates disregarding the year registered with the client? The current…
-
1
votes2
answers722
viewsCalling c# method in javascript
I created a method that calls data from a database in C#. How can I call this method in Javascript ? Follows code [WebMethod] public copa recuperaDados(int cAno) { var con =…
-
1
votes1
answer39
viewsSELECT GROUP BY SHOP
Good morning! I have 4 stores at 1,2,3,4 want to consult the last sale of a product of each store.bringing only the last 4 sales, but one of each store. someone can help me? select top 4…
-
1
votes0
answers20
viewsHow to query data saved in JSON in . Net Core’s Dbcontext
Hello, I’m having a question regarding how to query a list or even a single record that was saved in the database in JSON format. For example. These are the data saved in JSON format in the…
-
1
votes1
answer23
viewsQuery with two summation results from a condition
I need to perform a query in a table of sold items where there is a Tipoitem field that says if the item is Product(1) or Service(2), I would like it to bring me two SUM’s from one of the Ocisubtot…
-
1
votes1
answer28
viewsQuery to insert into a Sqlserver table
Sqlserver, given a table with the fields: id (int), name (nvarchar) and birth (smallDateTime) How can I write a query to insert into this table and then query this data from all table records. Id:…
-
1
votes1
answer29
viewsSQL SERVER delete record after UPDATE
I would like to know if you can delete the records from the source table after performing the UPDATE in another table, that is, delete the row (from the source table) that was used in the update of…
-
1
votes0
answers60
viewswpf application with Entity framework does not work on another machine
I have a wpf application with Entity framework and sql server express...works perfectly on my pc, but when I try to install it on another computer it does not work...the application does not create…
-
1
votes2
answers41
viewsVarchar operation in SQL 2014
I am trying to do a less sql account in sql Sever management but this format error. I am wanting to do the months account 202103 - 202101 = 2 months How to solve this format problem? select * ,DPD =…
-
1
votes1
answer54
viewsHow to compare only dates in Sequelize?
I am using ORM Sequelize and would like to compare only one date instead of the date with time. I have the following date: 2021-05-06 03:00:00.0000000 +00:00 And I’m doing like this: const dataAtual…
-
1
votes1
answer53
viewsRecover orders customer 1. DUPLICATION ERROR
My code: SELECT Pedido.NumPedido , Pedido.CdCliente , Cliente.Nome , Produto.CdProduto , Produto.Descricao , PedidoItem.Quantidade , PedidoItem.ValorUnitario , PedidoItem.ValorTotalItem FROM Cliente…
-
1
votes0
answers70
viewsElastic transactions with MS SQL Server
Considering the following code snippet: using (var scope = new TransactionScope()) { using (var conn1 = new SqlConnection(connStrDb1)) { conn1.Open(); SqlCommand cmd1 = conn1.CreateCommand();…
-
1
votes3
answers464
viewsdrop table with temporary table giving error
qryCIDtemp.SQL.Text := 'drop table if exists #tempCID'; //apaga a tabelas temporária Delphi returns me the following message at runtime: Invalid use of keyword Token: if Line Number: 1. If anyone…
-
1
votes3
answers113
viewsSQL Server - Query logic
Note the result below: This is the result of the following query: select *, isnull(h,isnull(f,isnull(d,isnull(b,isnull(a,0))))) as y1,…
-
1
votes1
answer44
viewsFiltering items in a products table
Good afternoon to everyone, I have a simple application that I am developing, and I have the following problem, I have a variable "Tenure List", which already has the ID of the items, and I have a…
c# sql-server entity-framework winforms visual-studioasked 3 years, 4 months ago Mecleudio Queiroz 31 -
1
votes1
answer481
viewsSyntax error in with SQL Server
Tenh the following error in sql server: Incorrect syntax near the keyword 'with'. If this statement is a common table Expression, an xmlnamespaces clause or a change tracking context clause, the…
-
1
votes1
answer880
viewsMultiple rows in a Sql Server column
I have a problem where I need to join the return of a query made in two tables in a single row. I thought I’d use PIVOT but I couldn’t because of INNER JOIN. The consultation is like this: SET…
-
1
votes1
answer75
viewsCreate a table or several in SQL Server?
I have tables in my database: Orcamento, Maquinas, Veiculos and Acessorios. I need to record the costs of each of them, for example each table will be recorded a daily cost I create a table called…
-
1
votes1
answer20
viewsCompare SQL Server users to AD users
I need to raise users of an instance that no longer exist in the AD for cleaning these. Is there any way to compare AD users with windows Authentication users of an SQL instance?
-
1
votes1
answer682
viewsUPDATE with several records from another table
I have a table T1 where I have the ID. I have a table T2 where you take the ID_T1(Foreign Key) of T1. I have a table T3 where you take the ID_T1(Foreign Key) of T1 and the ID_T2(Foreign Key) of T2.…
-
1
votes1
answer499
viewsList Missing Period Days in SQL Server
How would it be possible to do with what in SQL Server when confronting a table that stores the status records of a given code with a virtual table of the period (Calendar of days) it brings me all…
-
1
votes1
answer102
viewsHow to create a unique index in a table so that it only has a record with a specific value in Sqlserver
Hello, I am creating a data structure in Sqlserver and I have the following situation: I have a list of contact types (person, public, commercial, etc...) This list can be changed by the user but,…
-
1
votes0
answers289
viewsScan Excel table data and save to SQL Server (Asp.Net MVC 5 C#)
I have an input file that the user will upload the spreadsheet, I need to check if it is .xlsx or .xls and scan the data from this spreadsheet. After that, I need to save to Sql server those items.…
-
1
votes2
answers88
viewsQuery in SQL SERVER 2017
I need to perform a query in SQL Server 2017, where I need to bring the following information: Codigo do chamado, Data Abertura, Interação, Analista, UltimaInteração(would be the date of the last…
-
1
votes2
answers392
viewsSQL Server - CONCAT + IF in VIEW
I have a problem and I’ll try to explain the situation. I have a client chart called ENTIDADES, there is an attribute called ID_GRUPOECONOMICO where this is a FK table GRUPOECONOMICO. I’m creating a…
-
1
votes1
answer218
viewsPass object to proc sql server
Is there any way I can make a SP that receives an object? This is my SP ALTER PROCEDURE [dbo].[sp_alt_funcionarios] -- Add the parameters for the stored procedure here ( @id int, @nome varchar(60)…
-
1
votes0
answers68
viewsColumn number of supplied values does not Mach table Definition - SQL SERVER
I have the following problem in sql server when I put the CASE clause at the end of this line of code: DECLARE @RESULTADO TABLE ( Total INT, GrupoTitulo VARCHAR(255), GrupoChave VARCHAR(255),…
-
1
votes0
answers112
viewsUpload Datagridview photo and move to picturebox C#
Guys with little difficulty in picking up my registered photo and show it in Picturebox My scenario is this:: I have a registration form that makes the insertion of data and A form that searches the…
-
1
votes2
answers586
viewsWrite checkbox value to sql server database
I have a DataGridView and in it contains a checkbox, I need to save the value in the database, how can I do the Insert of this value in the bank, the field in the bank is as: 0=false e 1=true, Only…
-
1
votes1
answer924
viewsPassword Encryption Question - SQL Server
I am developing an ASP.NET MVC system, SQL Server database, which will have logins control, and to encrypt the password, I have developed the following functions and procedures: CREATE FUNCTION…
-
1
votes1
answer245
viewsI have a problem loading a field using a function in ADVPL
I need to load the field CK_XLOTE typing the code of the product in the field CK_PRODUTO, I am generating a function to perform this procedure, but it is not returning the lot in the field. Can…
-
1
votes0
answers36
viewsStock modeling for performance in Oracle and sqlserver
A stock table that will be widely accessed where I will have the quantity field being constantly changed with inputs and outputs which is most indicated in the matter of tunning and performance? 1-…
-
1
votes0
answers25
viewsSSDT SQL71561 reference error not solved
I created a database project for Azure SQL Database using visual Studio (SSDT). For now I have only two tables: CREATE TABLE [dbo].[ServiceOrder] ( [Id] INT NOT NULL IDENTITY, [Name] VARCHAR(50) NOT…