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
answer202
viewsSELECT with intermediate table returning all values in the same field and separated by comma
I have the tables (and their relationships) of the diagram below: I need to do this: Bring all the fields of the TBCADCRE table and an extra column called ADQ with all the TIPADQ that the user has…
-
1
votes0
answers115
viewsJumping id 1000 Sql server 2014 (localDB)
In my application a few times when I will add some data to the database the ID jumps in 1000 drives. I found some solutions, but they are not good for me because I use EF6 with code-first and my…
-
1
votes0
answers32
viewsRun ALTER on a PROCEDURE that is referenced by another object
I’m trying to change/drop the function [xxxx] according to the code. But the following error returns to me Msg 3729, Level 16, State 3, Procedure xxxxx, Line 1 [Batch Start Line 15] Cannot ALTER…
-
1
votes0
answers100
viewsHow to validate a Case result
How to validate a Case result I’m taking the interval between two dates in days, I want to validate if the result and more than 120 days, has a better way than I’m doing? DECLARE @DataInicioVigencia…
-
1
votes1
answer43
viewsError when modifying a View column with calculation
I need to insert a calculation column in this view below, but the message appears Msg 205, Level 16, State 1, Procedure Consolidadoestudobasesifix, Line 4 [Batch Start Line 9] All queries Combined…
-
1
votes2
answers1012
viewsDuplicate keys
** Improving the Post to better understand what happened. Person, good afternoon. I created a table 'client' in sql server and put the email field as vachar(50), Unique and null accept pq by logic,…
-
1
votes0
answers21
viewsHow to integrate a Class Library to a Database Project in Visual Studio
Hello, I am creating a solution in Visual Studio in which I would like to separate all layers of the application in projects to have a better defined structuring. My solution until then is like…
-
1
votes2
answers193
viewsTimeout Sql Server in a request via Web Api
Running the query gives a Timeout Sql Server error: Connection Method: public SqlDataReader GetDataReader(string comando) { SqlConnection conn = criaConexao(); // Cria Comando SqlCommand cmd = new…
-
1
votes1
answer35
viewsHow not to repeat data in this query
I did this query, which will compose a view. SELECT DISTINCT US.EMPLOYEESTATUS ,US.EMPLOYEEID ,US.EMPLOYEEFIRSTNAME + ' ' + US.EMPLOYEEMIDDLENAME + ' ' + US.EMPLOYEELASTNAME AS FULLNAME ,US.GRADE…
-
1
votes2
answers48
viewsApply condition depending on value
In the script below, I need to use a condition only if the field is filled (line is commented in script below). If not, this condition should not be part of the query. Is there any way to do this…
-
1
votes1
answer617
viewsGrant permission to a new user in SQL Server 2014
I’m trying to assign permissions to db_datawriter and db_datareader a new user in SQL Manager The following steps have been executed: -- criação do usuário CREATE LOGIN apostila WITH PASSWORD =…
-
1
votes1
answer43
viewsProblem with Join and sub-consumption
I have an exercise to answer, however I can not get the complete solution, only partial ideas, the DBMS used is SQL Server. Considering the Customers, Orders and Order Details tables create an SQL…
-
1
votes1
answer67
viewsHow to make a query in SQL that brings a count of some results
Next, I am developing a query in SQL and the purpose of this query is to Count the records that reached the value below 99,7%(As I have the data for this already calculated and transformed in…
-
1
votes2
answers211
viewsInsert problems in Asp classico (replace)
Guys, in my database, the column is set to numeric (18,2) then I have a field in a form that the person type the value and it goes to my table. the insert is like this: entrada =…
-
1
votes0
answers67
viewsVariable is not populated in Procedure
Good morning. I am running the file below, which validates whether the load should run or not, and if it is not possible to run, returns an error message stating why it did not run: declare @dtAtual…
-
1
votes2
answers1538
viewsReturn 3 months previous from day 1
Every Friday I need to generate a report that brings me transactions made in the last three months. However, I have to pick up from the 1st of each month, for example, we are in the 9th month, so I…
-
1
votes0
answers44
viewsAPP terminates unexpectedly on smartphone
Below is the code and the logs. I try to run, but always closes the app unexpectedly. It closes without showing the error image or inserts in the bank. package... imports public class Cadastro…
-
1
votes1
answer225
viewsselect distinct in temporal table sql server
I have the following code: (is from a table that the representatives have the same code, which generates duplicated values, I solve this by taking the most current representative, in short the last…
-
1
votes1
answer266
viewsParameters for query in sql server
Good morning.. I have a query in sql server with date and status columns, I need to bring the result by the date typed or by the state typed or by the two, as I can do this right in the query in sql…
sql-serverasked 6 years ago Junior Guerreiro 617 -
1
votes1
answer240
viewsQuery joining two tables and filling in fields conditionally
I’m a beginner in SQL and I was wondering if you could help me with a question. I have two tables, one is called Cadastro_func and the other Cadastre. The 'Func_register' has the columns: 'Nickname'…
-
1
votes1
answer182
viewsSelect with PIVOT always returns null
I’m trying to do a query using the pivot based on this link insert link description here, but without success, as it always returns 2 Null lines: Query: DECLARE @registros as table ( ID int, Campo…
-
1
votes1
answer720
viewsHow to add sql values in column
I have the following sql code: select PS.PatSldBemValResidAnt ,PS.PatSldBemValDepAcum ,Sum(PS.PatSldBemValDep) PatSldBemValDep ,Sum(PS.PatSldBemValResid) PatSldBemValResid from Pat_Saldo_Bem as PS…
-
1
votes1
answer428
viewsDelete all records from a database except a user
I have a database that I need to delete all records that exist in it, except one user that is in the table User linked to another table (Aspnetusers). I’ve made a few attempts to SSMS, but always…
-
1
votes1
answer71
viewsHow to Relate a Table to Another Table where the field to relate is an XML
I have an SQL Server database from a system that has been discontinued. In this database, there is a table MOVIMENTACAO and a table EQUIPAMENTO, where would set up a relationship N:N. The problem is…
-
1
votes3
answers283
viewsNo Fill new column as Null, yes with specified value in script
I have a specific table in the database, in it I keep information of classes that are created, swimming classes, futsal classes, weight training classes and so on, it is already in use and with…
-
1
votes2
answers210
viewsSQL Server foreign key is giving null value when entering data in the main table
Good! I’ve been learning sql for about a week now and I’m having some problems understanding how Foreign Keys work, specifically by creating Inserts in an application where Foreign key(foreign key)…
-
1
votes1
answer367
viewsWhen firing an Update Trigger, one of the fields only updates after a second Update
I created a Rigger to inform the fine about the delay of returning rented movies, however, when firing the Rigger once (giving an UPDATE), the field "Total Fine" does not update (only it). But when…
-
1
votes1
answer51
viewsFilter query by removing duplicates
Good afternoon, I’m with the following select: select codemp, codfunc, codevento , vlrevento from sankhya.TFPFOL where codemp = 1 and codfunc = 26 and month(referencia) = 1 and year(referencia) =…
-
1
votes2
answers1911
viewsCreate Trigger to change record only when modifying a field
I have a SQL Server registration table, I have a column that shows the status of this registration ('A','I','S','C'). I created a field with name Update_data, that you will receive a datatime every…
-
1
votes0
answers62
viewsImport Excel that does not have standard for SQL SERVER with C#
I have the following scenario: I have an Excel spreadsheet that is provided by several private companies. This spreadsheet contains social security data. The problem is this: I have columns that…
-
1
votes1
answer36
viewsAssemble query for specific scenario
I have a table with the model below (consistent data): CODIGO | INICIO | FIM 1 | 2018 | NULL 1 | 2017 | 2017 1 | 2014 | 2016 I need to find the records where the INICIO has the same value as FIM…
sql-serverasked 5 years, 10 months ago w-all 67 -
1
votes0
answers19
viewsjpgraph Empty square php line Chart
Here my code receive data of a form: if(empty($_POST["GESTOR"])) { $where_GESTOR = ""; } else { $GESTOR = implode( "','" , $_POST["GESTOR"]); $where_GESTOR = " and B.GESTOR in ('$GESTOR') "; }…
-
1
votes1
answer69
viewsTreat a column of the same table twice and present as a record in the same column
Good afternoon Dear Friends, I am developing a report with some necessary standards, I will not delve into the standards for the query, but fact is that I "managed" to make a Query with the…
-
1
votes1
answer1512
viewsSQL use of LEFT JOIN with OR
I’m new to the SQL and I have the following question concerning LEFT JOIN: I have to list a table of cliente where each customer has a id and a code client with another table containing the…
-
1
votes1
answer291
viewsHow to load data into a combobox whenever registering new values
How do I make sure that each course registration is automatically updated the course combobox without having to close and open the application again? Ex: I register a course "Administration" and…
-
1
votes1
answer541
viewsSQL Server and PHP error: "The Wait Operation timed out."
I’m trying to connect to a SQL Server database using PHP, but the operation is timed out. Using SSMS (Management Studio) with the same information as the PHP string, it is possible to connect…
-
1
votes1
answer381
viewsBring last date of SQL Product
I am performing the following consultation to bring the products with their last sale date: SELECT P.ID AS 'Código', p.Nome, CONVERT(decimal(18,2),pe.Valor_Custo) as 'Custo',…
-
1
votes1
answer106
viewsCount repetition amount of an item
I have a table where were inserted several repeated items, I need to return all these items that have more than one register. So I made the following query: SELECT COUNT(ID), CODIGO, DESCRICAO,…
-
1
votes0
answers64
viewsI am unable to validate the authenticated user
PROBLEM: I am unable to validate the user authenticated by the database. What happens is that when I run my application, putting valid user and password, it returns me false inside my loginOk…
-
1
votes0
answers26
viewsSqlserver Dynamic PIVOT
I have a table that stores the EST_PROD_CD_BARA barcodes of the products, however, I would like to bring all the Eans of an item in just one line based on the id (cd_prod), since, a product can have…
sql-serverasked 5 years, 9 months ago Gean Santos 11 -
1
votes2
answers1011
viewsMsg 8114 error in SQL Server while performing query
I’m having a problem executing a query in the SQL Server, where I try to bring a column with a conversion of done in a column like DATE and another column with an HTML code mounted. Follow the query…
-
1
votes0
answers341
viewsSQL using Join with subquery
I have the following code: select FACAV_CDMATCOOP,CCCCO_NOCOOPERAD,FACLA_ORIDAVIAR FACLA_QTPESOLOTE, FACLA_QTENTREG1, FACAV_ORCDAVIAR, FACLA_NRLOTE, FACLA_DTYALOJA, FATCR_QTPESOMED from FACAV F…
-
1
votes0
answers200
viewsNullreferenceexception - Object Reference not set to an instance of an Object
A person is launching a proposal, and I found through the Iderro generated on the page that she is accessing this error below. But I can’t understand his motive, so help me?…
-
1
votes1
answer418
viewsHelp with a PIVOT ( Sql Server )
Guys I looked for many examples of Pivot but I could not understand... and I’m just not able to use in my select... what happens, I’m having this result :…
-
1
votes2
answers127
viewsPrevent Insert or Update If date is in a Registered range
I am with the following doubt: I have the table: Escala Data_Atuacao_Inicial, Data_Atuacao_Final, tipo The guy can be 1 or 2 I want to create a Rigger to stop the Insert or update of this table, if…
-
1
votes1
answer56
viewsDatabase error that appears when updating the page - SQL server
I have a system made in CODEIGNITER where several users access simultaneously, and lately I’m receiving complaints that on several pages of the portal, appears the following error: "Unable to…
-
1
votes2
answers58
viewsAndroid + Volley with PHP connector returns error!
I am trying to connect and send a registration, via PHP Nector, from my Android application to SQL Server on the local computer. It’s returning "Error!" because it looks like Volley doesn’t see the…
-
1
votes1
answer525
viewsInner Join in Procedure
I am creating a small database on SQL Server, for an ASP.NET mvc project of my course. Using ADO.NET I am creating procedures, to use in my DAL class, so far everything well has a lot of information…
-
1
votes1
answer68
viewsAndroid + Volley + PHP Connector Does not insert data into SQL Server database
I’m trying to input data from an Android application into the SQL Server database, and I’m using Volley and PHP Nector. The connection is ok, and searches usually appear on the device screen. I need…
-
1
votes0
answers35
viewsDoubt Code (Charset) Soapclient Laravel
I would like to understand the reason for this difference in a consultation using the SOAP: In an application the SOAP query returns a string in format ASCII, with special characters of shape of ??…