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
-
3
votes2
answers1174
viewsExport sql server query result to txt file on apache server automatically
I do the following query of my apache server in an SQL SERVER database: <?php // Dados do banco $dbhost = "192.168.0.100"; #Nome do host $db = "DATABASE"; #Nome do banco de dados $user = "root";…
-
3
votes4
answers5888
viewsSelect with multiple Left Joins Sql Server
I took an example of people registering with the following structure: I’m trying to make a SELECT in tblPessoa with JOIN with the intention that select returns data from the table in which Id…
-
3
votes2
answers83
viewsDatabase connection problem
I am building an application from Netbeans IDE 8.1 and accessing the database developed in Sql server further when running the application this generates error: Connection error The port number…
-
3
votes1
answer6636
viewsHow to calculate the average using conditions in SQL Server?
The question asks me to show the number of students with averages greater than 7, less than 7 or equal to 7 for some tables I have here. Thus showing: How to create this column of Description?…
-
3
votes1
answer39
viewsAccess SQL Server 2008 data from Mysql
Does anyone know if I can access data from an SQL Server 2008 database from a Mysql database? It would be something like Linked Server, but the other way around.
-
3
votes1
answer124
viewsDump Database
Is there any way of knowing whether or when a DUMP of a database?
-
3
votes1
answer1018
viewsError converting from varchar to smalldatetime
In the query below the following error occurred: Conversion of a data type varchar into a data type smalldatetime resulted in a value outside the range. Looking at it, I realized that if I take the…
-
3
votes2
answers6454
viewsHow to use Sum with subquery
How can I use the sum with a subquery inside? I tried many ways, but I couldn’t. When I try to put the sum shortly after the select main, message appears that I cannot use aggregation function with…
-
3
votes2
answers1003
viewsHow to display total rows of a table in a label
I don’t know how to pull the total lines of a table, code: public string Eventos { get; set; } SqlCommand comando = new SqlCommand("SELECT count(*) FROM Active", conn); SqlDataReader leitor =…
-
3
votes1
answer219
viewsHow to evaluate which command to use between truncate/delete
I was reading about these commands Truncate table and Delete from, where I saw this explanation Truncate table - This command removes the watermark from the table by cleaning the same for a next…
-
3
votes2
answers2319
viewsHow to use like in a comparison of fields in different tables?
How can I use the LIKE for a comparison of two different table fields? I need to compare the first 5 characters of each field. I tried with SUBSTRING and with LEFT, however, the performance gets…
-
3
votes1
answer505
viewsUpdate in two SQL Server tables
How do I perform an update at the same time on two different tables? I have a table called Tarefa and another call VinculoReferencia, both have the field Taridinclusao where is this field that needs…
-
3
votes3
answers775
viewsHow can I make a copy of multiple tables in a new table using SQL SERVER?
I have several tables with the same number of columns. and I want to insert the records of these tables into a new table. Anyone have an idea? because I only managed to insert one and does not…
-
3
votes2
answers80
viewsHow to create a condition that does not include the month of December?
I am creating a condition to be executed before the month of December, IE, only runs in the period of january to november year-independent. IF (SELECT TarFechamento FROM Tarefa WHERE TarID =…
-
3
votes2
answers1367
viewsConversion failed to convert varchar 'No' value to tinyint data type
I am trying to solve a patch error of converting a variable created by me to store data that is in an Excel sheet. The error happens when I try to insert the data that is in this variable in SQL…
-
3
votes1
answer69
viewsHow to identify the Entity that throws the error when saving?
In my application, with Entity Framework, I make a query in a Round entity: var lista = contexto.Rodada.Where(condições); Then I’ll go over that list with a foreach. During iteration "updates" and…
-
3
votes1
answer243
viewsJOB with 2 Steps, first step stops when reaches 1 minute of execution
I have a JOB configured in SQL to run every 30 minutes, in this has 2 steps, 1 Process in each step, but when the first step reaches 1 minute of execution, it ends without executing all records that…
-
3
votes2
answers1649
viewsOptimize a data transfer from one table to another SQL SERVER
SQL SERVER Database I have two tables, one with 2 billion records and the other with 16 billion. I am copying the first to the second. Using the INSERT INTO table2 SELECT * FROM table1; Doesn’t work…
-
3
votes1
answer241
viewsC# class as parameter in SQL Server
You can create a class in C# and the same class in SQL Server that represents a tabela (ID, Nome, Telefone) and create a precedent where I would pass as parameter this class . This is the class…
-
3
votes1
answer431
viewsHow to import XML from Data Dictionary to SQL Server?
To put it in context, I’m making a data dictionary for a local database, so I used a tool called "Database Notetaker". This tool loads the database data and allows me to comment on the table data…
-
3
votes1
answer370
viewsSQL Server PDO error: There are no more Rows in the active result set. Since this result set is not scrollable, no more data may be retrieved
I’m trying to take records from one table and record in another of the same kind, but I’m having this error: There are no more Rows in the active result set. Since this result set is not scrollable,…
-
3
votes1
answer8878
viewsGenerate table Insert script in sql server
Using Sql Server 2012. I made a query with the title above and did not bring anything in the search. I have a BD and need to take it elsewhere. Therefore, the best way is to generate a script of all…
-
3
votes3
answers847
viewsHow to create Login and User in SQL Server passing command line through Visual Studio passing parameters?
public void CriaUsuarioSystem(string userSystem, string pwSystem) { try { conexao = new SqlConnection(conexao_BD); SqlCommand creatUserSystem = new SqlCommand("CREATE LOGIN @login WITH PASSWORD =…
-
3
votes1
answer796
viewsHow to authenticate user via AD or via SQL Server Database
The user has to access via Active Director authenticationy when you are in the premises of the Company and when you are outside the Company the access will be via login and password query in an SQL…
-
3
votes1
answer7859
viewsSql Server - View the View structure
I executed the following commands in the Sql Server database: comando 1: SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'vendas' resultado 1: TABLE_CATALOG TABLE_SCHEMA TABLE_NAME…
-
3
votes1
answer272
viewsDynamic attributes of an Entity Model
I have a Procedure which returns a number of columns dynamic, because this precedent uses the function Pivot, then the question arises: How to create a Entity Model for this project ?. Example:…
-
3
votes3
answers1235
viewsReplace value null
I wish that when you came null in my select replaced by 1900, follows select: SELECT (SELECT TOP 1 tabela1.data FROM tabela1 tabela1 WHERE tabela1.id = tabela2.id) as data FROM tabela2 tabela2…
-
3
votes3
answers5999
viewsseveral values for a column in Where
Is there any way to put several values for a column in WHERE? For example product A was replaced by product B, product 2933 for the 4044, product 2599 for 7845, and product 5987 by 9432. Example:…
-
3
votes2
answers419
viewsUnixodbc: Decimal Formatting Problem
I built a server with Centos 7, SQL Server 2017, and Unixodbc On tsql, the numbers are correct. But when I see in isql, the decimals are separated by a comma (,) rather than a dot (.). How can I fix…
-
3
votes1
answer152
viewsHow to allocate transactions or group by day?
SELECT COUNT(*) QTD_TRANSACOES, CD_RSP_RECUSA, SUM(VL_AUTORIZADO) VALOR_SOMATORIO, CASE WHEN MR.DS_MOTIVO_RECUSA IS NULL THEN 'CÓDIGO DE RECUSA NÃO CADASTRADO' WHEN MR.DS_MOTIVO_RECUSA = 'APROVADO'…
-
3
votes3
answers756
viewsTransform a Json Array into another JSON using Node
Good morning, I’m having a problem assembling a JSON using Nodejs. I have a return of a giant SQL that basically follows the structure below. [ { "numDoc":"0000001", "OutrosCampos":"outrosDados",…
-
3
votes0
answers54
viewsWhat are the means of replicating tables between SQL servers?
When developing a project, I came across the following situation: We have a system, where users enter information during the production process, and in the end a report is generated. This data is…
-
3
votes0
answers570
viewsc# Error: "Object Reference not set to an instance of an Object"
I am trying to make a connection to sql server in an Xamarin application for android, however the application presents this error: Object Reference not set to an instance of an Object Connection…
-
3
votes2
answers58
viewsLeft Join in SQL
SELECT SUM(TAXAS) FROM DOCUMENTO LEFT JOIN PARCELAS PARCELA IN (PARCELA.CODE = DOCUMENTO.CODE) WHERE PARCELAS.FATURADAS = TRUE I’m getting a syntax error I can’t fix
sql-serverasked 6 years, 7 months ago Fernanda Neitzke 33 -
3
votes2
answers878
viewsHow to get the number of columns of a temporary table
How is it possible to obtain the number of existing columns in a given temporary table in sql server?
-
3
votes3
answers1439
viewsDifference between SQL SERVER dates
I have a question on sql server. Based on the table below, how can I catch the difference in days which takes to go from one phase to the other of the same client, ie difference phase to phase.…
-
3
votes1
answer4972
viewsSELECT in VIEW generates sub-query?
I wonder if I make one VIEW with a simple query, whether the view call generates a new SELECT, ie a sub-SELECT totaling 2 SELECTS or whether it only points to SELECT from within the VIEW? I only ran…
-
3
votes1
answer172
viewsQuery SQL Server Error
I have the following SQL: INSERT INTO SISCli…
sql-serverasked 7 years, 3 months ago KevinF 1,332 -
3
votes1
answer140
viewsQuery - Bring 5 major records
I have the query below, where I need to bring only the 2 largest columns that have the highest values. Today is coming out like this: Conciliacao Extrato Integração 150 140 80 That is, I wanted to…
-
3
votes4
answers1722
viewsHow to recover a value from within a tag in XML?
I have a table called SPDNFE with a column DsXML which contains all the contents of a Xml. Query: SELECT top 1 SPDNFE.DsXML FROM SPDNFE where SPDNFE.CdIdNFe =…
-
3
votes1
answer398
viewsUser permissions
I’m having a hard time configuring a user’s permissions in sql server: Today I have a user who is currently the db_owner, I want to take this access from him, but I need this user to have full…
sql-serverasked 6 years, 5 months ago Leonardo Palmieri 71 -
3
votes1
answer811
viewsHow to display 2 BD tables inside a Datagridview in the application?
I have an application developed C# using the project Windows Forms that displays the People Database Table in a list in the field DataGridView. However I need to show in DataGridView also the table…
-
3
votes1
answer94
viewsCheck between date ranges?
Table Ciclos: I have the date 2018-07-05 How could I ride a query between the intervals of CiDtIni and CiDtFim according to the date above?…
sql-serverasked 6 years, 4 months ago Igor Carreiro 1,917 -
3
votes2
answers1365
viewsHow to make paging in Sqlserver 2008 R2?
I tested with two forms, but did not succeed. select * from table OFFSET 10 ROWS select top 10 * from table OFFSET 10 ROWS FETCH NEXT 5 ROWS ONLY Interestingly I never had to offset this version of…
-
3
votes1
answer64
viewsI need help to transform this SQL into a LINQ
I have the following SQL: select conferencia.tb_conferencia.con_codigo, con_pedido, count(coi_codigo) as countItens, count(distinct cic_conferencia_item) as countItensConferidos from…
-
3
votes1
answer451
viewsRecover value using Node.js and mssql
I’m having trouble recovering a value using the mssql library I tried to put a variable in the global scope and update the value using recordset, put everything inside a function passing the value…
-
3
votes3
answers1110
viewsHow to find "holes" in SQL Server tables?
I have a table with a column id (primary key, auto increment value 1). My application nay allows lines to be excluded, hence the expected query SELECT id FROM tbl ORDER BY id ASC that would be it:…
-
3
votes2
answers1482
viewsSQL: Doubt in the Relationship between Tables
I am creating an academic system that consists of a virtual restaurant menu type, for this, I created three tables in the bank: Table of Menu Items: CREATE TABLE ITEMS( ID INT PRIMARY KEY NOT NULL,…
-
3
votes4
answers9972
viewsHow to get the month and current year in SQL?
How can I print the current month and year on the screen in sql ? I need the month to be extended. I’m using the query below. select GETDATE() from DUAL Currently it is being printed as follows.…
-
3
votes1
answer3146
viewsTurn rows into a select column - PIVOT - SQL Server
I have an SQL query that returns the following result: Consultation +--------------------------------------------------------------------------+ | CONJUNTO | TIPO | FILHO | PAI | TIPO_CONTEUDO |…