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
answer70
viewsError connecting SQL Server to Java in Resteasy API
I’m using the driver JDBC from microsoft 6.0 in a design of an API using Java (JRE 1.8) with resteasy using Eclipse Oxygen and Tomcat 7 (I tried with other versions and presented the same behavior).…
-
0
votes1
answer187
viewsSearching character in Specific Position - SQL Server
Hello, can anyone help me? I am building a query and I came across some problems in the way the bank was structured. I have a base with several phone numbers, and I need the 5°digito to be = 9. I…
-
0
votes1
answer61
viewsIt is bringing the whole column and not only a specific id
I’m trying to catch the last mile registered on the seat of a specific vehicle, but it brings me all the miles and not a specific vehicle. My Controller: var Rota =…
-
0
votes1
answer372
viewsIdentify the change of record in a time table?
I am working on a table that keeps the history of some people, and I need to identify and display the lines that have been modified in a certain column. See example: --Tabela HistSituacaoPessoa id |…
-
0
votes0
answers586
viewsRemove SQL Server special characters
how do I remove special characters from a string in a query in SQL Server with tags in html, xml and others? Current result: <!--[if !mso]><styl>v\:* {behavior:url(#default#VML);}o\:*…
-
0
votes1
answer640
viewsHow to Count With Subquery
I need to count table fields, however, these fields have different types of filters within Where. I need to be shown the consolidated information, I tried to do openquery but returns error. select…
-
0
votes2
answers68
viewsError 102 in Openquery
I’m making this mistake: Incorrect syntax next to@SQL_LINKED.. Error 102. SQLSTATE 42000. Severity 15. Msgstate 1. Line 78. When trying to run this script : SET @SQL_LINKED = 'SELECT CAST(v.produto…
-
0
votes2
answers44
viewsChanging positions of an integer
Citation I am building an sql where I have the following information yyyymmdd 20190327 is in the database as integer, I need to convert into ddmmyyyy 27032019 continuing to be an integer in select.…
-
0
votes0
answers83
viewsSQL Identity declared (1, 1) inserting 0
I have a serious problem in my database. Some of my tables were created with Pk and Identity (1, 1) which is standard. However, when restoring the database some of these tables get PK NULL and when…
-
0
votes2
answers42
viewsSQL formatting field
I have the following structure: |VALOR| | 1 | | 23 | | 5 | | 41 | I have a need to transform: | VALOR | | 0001 | | 0023 | | 0005 | | 0041 | Is there any function I can do that?…
-
0
votes2
answers70
viewsDoubt in an SQL DISTINCT
I have the following select: SELECT DISTINCT CD_CLIENTE, CD_CONTRATO, CD_AGRUPADOR FROM TBP_IMPORTAR_OS_RESIDUO WHERE CD_USUARIO = 0 But I wish when the field CD_AGRUPADOR were the same, bring only…
-
0
votes0
answers50
viewsDoubt PHP + Sql server
Good Afternoon everyone I’m new to the forum so I don’t know if I’ve opened this topic in the right place. I need a help in a table that I am generating with php through some queries being one in…
-
0
votes2
answers330
viewsPHP (Between + Convert Date)
I’m making a screen in php where the user has the date filter to extract a report from the database SQL Server, but the Mysql displays the default date mm/dd/yyyy, and I need him to turn dd/mm/yyyy…
-
0
votes1
answer1693
viewsGroup and add to a query in SQL Server
Good afternoon, I have the following problem: I’m developing a C# program for internal company data query. It is working perfectly, but I need to group field(s) and add another(s) that contains…
-
0
votes2
answers53
viewsDoubt about Querys
I am trying to create a view to return the query of a Query. My problem is that I wanted to return values for each product and is returning the same value for the products. SELECT B.ID_Caso,…
-
0
votes1
answer38
viewsSqlquery - Some Duplicate Records
Guys, in the query below is bringing the following way. UsuID Consultor Tentativa 1 Abertos 95093 Gabriela 96 However, it was to bring in the following way: UsuID Consultor Tentativa 2 Abertos 95093…
-
0
votes2
answers264
viewsRemove First Name and Last Name from Full Name
I am using the SUBSTRING_INDEX command to get the first name and last name of a table field "Names". SELECT SUBSTRING_INDEX(nome_completo, ' ', 1) AS primeiro_nome, SUBSTRING_INDEX(nome_completo, '…
-
0
votes1
answer597
viewsI cannot create the connection to the database in my php file
I’m trying to connect with the bank but only appears this error: Fatal error: Uncaught Pdoexception: could not find driver in C: xampp htdocs PDO Example-02.php:3 Stack trace: #0 C: xampp htdocs PDO…
-
0
votes1
answer795
viewsDivision between values - Query SQL Server 2012
Guys, in the query below, is bringing the following way. Ano Mes Horas total_horas 2018 1 107 766 H 2018 1 225 766 H Therefore, I want you to bring in another column the division of the column…
-
0
votes1
answer87
viewsHow to update to a column of another table automatically when doing an update using Trigger?
CREATE TABLE TB_Empregado( nome varchar(50), rg int primary key, cpf varchar (11), salario money ) --- CREATE TABLE TB_Dependente( rg_responsavel int constraint fk_TB_Dependente_Empregado references…
-
0
votes2
answers495
viewsConcatenate SQL Server
I have the following appointment: SELECT UPPER(admatribuido) AS [admAtribuido], Count(admatribuido) AS [quantidade_admAtribuido] FROM ##tmp WHERE Month(dataabertura) = Month(Getdate()) AND…
-
0
votes1
answer42
viewsEntity Framework bank creation
I’m new to Entity and I’m following a step by step to create a Code First application ( http://www.entityframeworktutorial.net/code-first/simple-code-first-example.aspx ). I created the application,…
-
0
votes0
answers50
viewshow to view SQL executed by sqlsrv_query
I run the following code: $sql = "UPDATE [dbo].[NOTA_FISCAL] SET [STATUS] = ?, [USUARIO]= ?, DATA_TRATAMENTO = (getdate()), [MOTIVO_CANCELAMENTO] = ? WHERE [ID_NOTA_FISCAL] = ?"; $params =…
-
0
votes0
answers20
viewsFailure to Implement Reporting with Reporting Service
I have a report developed with SQL Data Toosl but when trying to implement it I get the message that the server has not been located, but it is configured in the properties of the report. It follows…
-
0
votes1
answer34
viewsJOB LINQ to update values in the database!
I have a JOB in which I need to update all the values to the maximum value that exists for a column, but my code is not working. Can someone help me? My code: List<SqlOnlyCostModel> costat =…
-
0
votes2
answers52
viewsDoes SQL Educational SERVER have fewer resources?
Good afternoon, you guys, Today I came across a company that uses in production SQL SERVER Educational, I know that this is not correct because this tool is only for non-profit study. But even so, I…
-
0
votes1
answer69
viewsLock in SQL Server and Oracle
Hi, I’ve been running some lock tests on SQL Server and noticed a difference from Oracle. In oracle I did an update on a line without effecting commit or rollback and in another session I was able…
-
0
votes0
answers31
viewsDatagridview does not store information in the table
I have a datagridview that is powered by a search in a database to carry out a sale but I can only sell one product at a time because the sales table cannot receive 2 or more products simultaneously…
-
0
votes1
answer732
viewsError creating Foreign key
I am creating two references of Foreign key pointing to two different tables, however I am getting error in creating one of them. There are no Primary or candidate Keys in the referenced table…
-
0
votes0
answers142
viewsSQL server connection with android application
How to connect an android application to sql server database ?
-
0
votes1
answer1249
viewsCreate a Relationship Table (N:N) that relates to a Normal-Table and another Relationship-Table (N:N) in SQL Server 2014 Management Studio
I am trying to create this SQL Server Data Flock Script, but when I run the following error message: Msg 1776, Level 16, State 0, Line 161 There are no primary keys or candidates in the reference…
-
0
votes1
answer71
viewslimit users in the database
I searched and did not find how to limit users in a DB... I am making an application in C# using 'sql server' and I would like to know how to make the userDB has a maximum of 5 users, when trying to…
-
0
votes0
answers40
viewsQuery - SQL Server with Stuff
Guys, in the query below I want you to bring it in the following way. contato andreia, marcos, juliana that is, on the same line. In the consultation, I used the stuff, but without success. Today…
-
0
votes0
answers183
viewsHow to not freeze/lock the application when querying data via SQL Server and create a "progress bar"?
The code below as an example brings me great information from the database. Every time I click on the "Search" option of my program, my application freezes/hangs for a while until the select "pull"…
-
0
votes1
answer236
viewsJava @Generatedvalue + SQL server NEWID + Hibernate
I have a table that has ID defined as CREATE DEFAULT ID_Tabelas AS NEWID(), that is, even if I use an Insert without the key, it will be generated automatically. How to make Hibernate recognize that…
-
0
votes1
answer52
viewsDate Subtraction and return positive SQL value
Good afternoon, I’m trying to build a Query in which I subtract two dates to return the value in days, but I only need the days that returned positive, I ran the Query that I assembled but had no…
-
0
votes1
answer37
viewsCTE: Union of two tables in which one of them has only one field in common
I need to do the following using a CTE.Imagining two tables with columns: Articles: Reference, Quantity, Price Associated References: Reference, Referral I intend that if there is an associated…
-
0
votes1
answer767
viewsError running SUM - SQL Server
Guys, I’m trying to perform the SUM according to the query below, however, the following error occurs. " It is not possible to perform an aggregation function on an expression that contains an…
-
0
votes0
answers127
viewsCompare values of two tables in a Procedure
I have an application that lists in a grid files that are registered in the table Scf_documentprocessocompra However, now I need to list only if this file also exists in the table SCF_ARQUIVO_UPLOAD…
-
0
votes2
answers282
viewsComparing date and time in different fields
I have a table that contains the following fields type name (nvarchar), Date of type (Date) and time like (Time). I need to do the comparison by period example: 08-02-2019 e 18:30:10 até 30-05-2019…
-
0
votes1
answer261
viewsUpdate an sql column of all records
I will try to be as specific as possible, if anyone can help me I really appreciate. I need to know how to change information in a column of all database records. For example: I have the database…
-
0
votes1
answer2207
viewsError convert Query SQL Server date and time
Guys, I’m trying to run the query below, however, the following error is occurring. " Failed to convert string date and/or time.". I have done some other conversions, but without success. select…
-
0
votes1
answer68
viewsError while running script
Guys, I’m trying to run the query below, however, the following error occurs. "Conversion of a data type varchar into a data type datetime resulted in a value outside the range.". select…
-
0
votes1
answer79
viewsExchange WHILE for GROUP in SQL
I need an SQL function to get data grouped by month. I have in the column CPCCodeID codes (ex: 512456). I need to count and group by the first two digits. I need it separated for months (!!!) and to…
-
0
votes3
answers3992
viewsConvert Date to year / month
I was able to convert the date to year / month, but I need the date to go like this: 2019/04, but it’s coming out like this: 2019/4 how can I fix this? SELECT CONVERT(VARCHAR(4), DATEPART…
-
0
votes1
answer85
viewscreation of a composite KP
I have two tables: tbl1 and tbl2. In the tbl1 I own a pk and in the tbl2 I own a FK which refers to PK of tbl1 and a pk. With this, I can make a pk composed for the tbl2 with these 2 fields ? EX:…
-
0
votes1
answer114
viewsOptimization of SQL-SERVER query
I need to get the field EMISSION_DATE of TLX_VENDA and the countryside B9_DATA table TLX_ESTOQUE_INI, but I need to do this within the OUTER APPLY. I managed to get the result but it’s too slow.…
sql-serverasked 6 years, 9 months ago Leonardo Palmieri 71 -
0
votes0
answers23
viewsSQL - Difference between Mandatorykey and Mandatoryfkey
I’m in my first internship since I started IT and the area I’m interning in is Databases. I have studied some old scripts and saw that some variables were declared, for example: @country AS…
-
0
votes2
answers75
viewsAdd SUM() to querry results
I have this querry that gives me the total number of lines that start with the same code USE CCILCDatabase; GO DECLARE @mes int; SET @mes = 1; WHILE (select @mes) <= 12 BEGIN SELECT…
-
0
votes1
answer911
viewsReturn data from 2 Entity framework tables
I have the following table: Moving -moving -Clienteid -Productoid When I select a particular customer I want to list all drives in which they are along with the product. what I would call it inside…