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
-
4
votes1
answer2845
viewsRemove Duplicate Space in Middle of String
Hello, I need to remove duplicate spaces in a string and leave only 1, identico a funcao arrumar do Excel. How to do this in sql?
-
4
votes3
answers6231
viewsHow to compare the structure of two SQL Server databases?
I need to compare the structure DDL of two databases, where one is the production bank and the other is the approval of a system. What tools can be used to do this?
-
4
votes1
answer308
viewsHow to cast exception in SQL and treat in C#
I’m creating procedures in an SQL Server database. To clear a brand, I first check if the brand is already tied to a product before deleting. CREATE PROCEDURE SP_Delete_MarcasProdutos @Id int AS…
-
4
votes1
answer427
viewsSearch only the smallest number of each letter
How do I search for only the smallest number of each letter, in Sql server? My table: Expected result: A - 1 B - 2 C - 1 D - 1 E - 3…
sql-serverasked 8 years, 5 months ago Brupikk 141 -
4
votes2
answers605
viewsField format for saving time
Which field should I use in SQL Server to save a duration? Ex.: 2days 23H 47min 00Sec. If you have an example with Fluent API it will help a lot.
-
4
votes1
answer114
viewsTime Usage with EF 6
I have a class with the following property. public TimeSpan TempoIdeal { get; set; } Estou atribuindo esta propriedade com TempoIdeal = new TimeSpan(days: 3, hours: 15, minutes:10, seconds: 0);…
-
4
votes1
answer373
viewsHow to check if there is scheduling in a time range?
I need to create an agenda where I allocate a service provider to work for a client. For example: Prestadordeservicos João will provide services to the customer condominium valley of the sun on the…
-
4
votes1
answer3721
viewsInsert X amount of characters in SQL Server field
Hello, I have two banks BDMCOM1 and BDMCOM1_V3_ALEA, both of which have a table called Saldodeproducts and the field called Codigodoproduto, in the table of the bank BDMCOM1, Codigodoproduto has 5…
-
4
votes1
answer206
viewsComparing Columns in SQL Server
Good afternoon! I wonder if you can help me. I am with the following case, we have a client who is with the version of our system VERY outdated, with this is missing several columns in the SQL…
-
4
votes1
answer500
viewsIs it OK to use SQL Server or Mysql with PHP?
I’m putting together a medium project and I’m going to model the bank, then create the tables, the views, as procedures beyond the bank itself of course. I would create everything with Mysql, but by…
-
4
votes3
answers372
viewsList dates calculated per month based on parameters
Based on two dates received per parameter, I am trying to list all dates per month (one date per month) based on the start date and up to the end date. These dates returned have to check the day of…
-
4
votes2
answers2566
viewsLogin with Windows Authentication on IIS
I have a base Sqlserver 2008 where all users can connect to it via Windows domain, this works properly via SQL Management Studio. I am making a C# Application in MVC, and I wanted that when the user…
-
4
votes1
answer3172
viewsHow to concatenate data into sql server
I have a field where the date and time is recorded: '2013-06-13 00:00:01' and '2013-06-13 11:59:59' I want to make an appointment by passing the date and a fixed time: CONVERT(VARCHAR(10),…
-
4
votes1
answer302
viewsProblem with left Join using Entity framework
I’m having a problem performing a left Join on Asp.net mvc. I own a view that lists all screens of the system, the same are registered in the database. I created a table of type (tab), screen and…
-
4
votes2
answers6935
viewsConcatenate values from the same column
How to concatenate the values of the same table Table example | Usuario | Formulario | Acao | Permitir | | Admin | Contrato | Imprimir | 1 | | Admin | Contrato | Consultar | 1 | | Admin | Contrato |…
-
4
votes3
answers75
viewsHow can I exclude the penultimate number from a period?
I’m trying to leave the period from 201601 to 20161 in SQL, but I can not at all! I wonder if someone could help me? SELECT CONVERT(NUMERIC(5), CONVERT(VARCHAR(4), YEAR(Periodo_Mensal))+…
-
4
votes2
answers2957
viewsI need a new Random number for each line in an sql(server) query
I use the sql server. I need to use a Random number in several different columns (the same Random number) but I want a new Random number for each row... for example, let’s assume that TABELAX has…
-
4
votes1
answer299
viewsHow to take a column in the database, perform a calculation and send it to the grid
I want to perform a calculation using the value of the VAL_VIDA_UTIL field of my BD and then save the result since calculation in a new variable VAL_DEPRECIACAO and pass to my fieldName, but I’m not…
c# sql-server webforms ado.net devexpress-asp.net-ajaxasked 8 years, 4 months ago Fernanda Ferreira 197 -
4
votes2
answers907
viewsHow to work with lock in SQL records?
I’m studying best practice to work with lock of records. What I mean is, I have several tables that can be accessed by several users simultaneously, but if any attempt is made to edit the record,…
-
4
votes2
answers657
viewsHow to list NULL on a LEFT JOIN even if it returns joins?
The situation found was that: I am making a junction between representatives and sellers, and in another situation this junction is made with another sales. There are sales without sellers but are…
-
4
votes0
answers4243
views'The underlying Provider failed on Open' C# ASP.net
I have an application that has 4 layers, which are the following : Dominio, Infra, Servico, Web in the domain I have a folder called Poco with all my Classes/Tabelas , in the Layer Infra, to test…
-
4
votes2
answers1404
viewsSplit string into substrings and search for them in another
I’m creating a function in which I will check whether a endereço_A contains parts in a endereço_B, exemplifying: address_A AVENIDA JOÃO E MARIA address_B RUA JOÃO The result should return JOÃO,…
sql-serverasked 7 years, 11 months ago Marcelo de Andrade 7,261 -
4
votes1
answer1934
viewsClass Factory Recovery Failure - Console Application
I have a Console Application that performs connection with the SQL. On other machines the application is working normally, but has one that has the version Windows Server Enterprise SP2 who is…
-
4
votes2
answers2348
viewsHow to make a user in SQL Server 2008 view only a VIEW?
I made a View to send to a customer, but I can’t pass the login and password to the general access. This way I created a user (cliente_view) and I would like this to view only the created View…
-
4
votes2
answers1111
viewsI am unable to configure the sqlsrv drivers in php7
In the archive php.ini all extensions are found, except the ones I need to connect to SQL Server database. extension=php_sqlsrv_7_ts_x64.dll extension=php_pdo_sqlsrv_7_ts_x64.dll As .dll are in the…
-
4
votes1
answer549
viewsDisable IIS cache
I’m having problems with IIS cache (I think the problem is he), whenever I make any changes in the database, changes do not happen on the website, keeps the old data. Changes only appear when I turn…
-
4
votes5
answers12287
viewsHow to perform SQL concatenation
I need to concatenate year and month. How could I do that? select cast(year(orderdate) as int) + ' ' + cast(month(OrderDate)as int) as Year_Month From sales.SalesOrderHeader…
-
4
votes0
answers285
viewsService returns me cast error when consumed
I decided to make another post, since the subject is another, although in the original post, in the comments we touched on the subject, but no depth. I have that mistake:…
-
4
votes3
answers438
viewsOver with Group by
I have a query that I use to return me as an extract, accumulating the values record by record: SELECT TOP (100) PERCENT Mes, Credito, Debito, Sum(Credito - Debito) over (ORDER BY Emp_id, Mes) AS…
-
4
votes2
answers1906
viewsCalculate Difference between 2 dates (has time in them)
Hello, I would like to make the following calculation. Starting Date = 11 September 2017 at 11:35 am Final Date = 11 September 2017 at 12:35 pm It should appear to me 1:10 am. Another example:…
-
4
votes1
answer114
viewsBind by SQL Server position using JS Node (MSSQL)
I wonder if it is possible to bind the parameters by position instead of the name using mssql in Nodejs. Ex.: //Por nome return pool.request() .input('input_parameter1', sql.Int, 10)…
-
4
votes2
answers2352
viewsReset datetime time with SQL
Today, man SELECT returns the following date: 2017-11-16 10:37:16.000 I’d like you to return 2017-11-16 00:00:00.000, can help me with this formatting?…
-
4
votes3
answers158
viewsDoubt about sql query
I have a question. I believe it is nothing complex, but I could not solve. For example, I have this query: select * from Paciente where ClinicaID = 3 Your result would be these 3 records:…
-
4
votes3
answers2090
viewsHow to add Count output from different tables in SQL Server?
How to add up the result of Count of different tables in SQL Server? Example: Table WORKS has 755614 Records SELECT count(*) from OBRAS; Table TITLES has 85106 Records SELECT count(*) from TITULOS;…
-
4
votes1
answer836
viewsSQL Server Composite Key
I have the following situation: I have a table ItensVendas where I need to apply a composite key to the fields VendedorId and ProdutoId, however I have some duplicated data, ie I can not apply the…
-
4
votes1
answer2459
viewsHow to use the merge statement in sql server
I would like to know how to use the instruction MERGE. When to use and what advantages and disadvantages to use?
sql-serverasked 6 years, 10 months ago Al Unser Albuquerque 965 -
4
votes1
answer3994
viewsReset Auto-increment SQL Server
Good morning, I created a new table in Sqlserver and I am testing some scripts to popular the table and I came across the following situation, in my tests I am doing the Insert in the table checking…
-
4
votes1
answer2689
viewsHow to access the local host from a Docker container?
I’m starting now with Docker and I’m lost in a small detail, I mounted an Ubuntu image with Apache, PHP 7 and the extension connection with SQL Server. How do I access the SQL Server server if it is…
-
4
votes3
answers2714
viewsFailure to log in to an IIS application when trying to connect to Sqlserver
When I run an application of the type website in visual studio, database connections work normally. But when trying to run IIS 7 to perform some tests, I get the following message: Unable to open…
-
4
votes2
answers94
viewsHow to perform a Where using Entity Framework
I have a web application that I need to present a list containing some data, for that, I created the Model: Crm_Analise: public class Crm_Analise { [Key] public int id { get; set; } public string…
c# sql-server entity-framework asp.net-mvc-5asked 7 years, 4 months ago Thomas Erich Pimentel 3,059 -
4
votes1
answer111
viewsBring only one product per affiliate to sql server
Good day I need to bring only one product per affiliate, but in my table I have several times the same product just changing the date, I would like to take the product of the last date. What do I…
-
4
votes1
answer682
viewsMaking the Insert in SQL Server in a float field?
I have the following problem in my code, I have a textbox that receives the value 0.900, only when I’m recording this value in the bank, it’s only recording 900, and I need you to record the 0.900…
-
4
votes3
answers124
viewsSelecting Active Batch
I’m studying about appointments at Sqlserver and have the following scenario: I have a lot table that has the following fields: Table of Lot (Lot) Id INT ProdutoID INT Preco SMALLMONEY Inicio…
-
4
votes2
answers178
viewsHow to update all records of all tables that have FK of a table
I have the following tables: CREATE TABLE Contrato ( [Id [int] NOT NULL IDENTITY, [Nome] [varchar](150), [Ativo] [bit] PRIMARY KEY ([Id]) ) CREATE TABLE [dbo].[ItemContrato] ( [Id] [int] NOT NULL…
-
4
votes3
answers759
viewsThe null value automatically becomes 0
I’m doing a vehicle registration, I need it to register put that whenever a vehicle is registered the value zero instead of putting the value null, I tried by default, but it does not record the…
-
4
votes1
answer1716
viewsHow to create a single index based on two columns?
I have a table with these columns: ip nome email I want you to ip and the email are a single pair. The same ip may contain several records and a single email may also. But the same ip and even email…
-
4
votes2
answers2954
viewsSearch XML field information in SQL
I need to perform a search inside a field where it stores an XML The XML is from a CT-e and in it has a series of tags and I need to find a data within a specific tag. Below the structure of the…
-
4
votes1
answer3377
viewsWhy is the use of ';' mandatory in the WITH clause?
I’ve always used the WITH in my consultations, however, I never understood exactly why is required the ';' before the clause WITH. The Error is very succinct, but it gives an idea that the WITH…
-
4
votes1
answer618
viewsPicking Gaps in an SQL sequence
Hello, today I own a select that returns me the following result: I do another select that returns a value, 5 for example. I would need to know which numbers are not between number 1 and number 5.…
-
4
votes2
answers213
viewsHow to filter only the last day of each month?
How can I filter a query bringing the result by the last day of each month, in SQL Server 2012? I tried the EOMONTH, I think due to the version. SELECT E8_FILIAL, E8_AGENCIA, E8_CONTA, E8_DTSALAT,…