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
-
2
votes1
answer515
viewsMaintenance routine for cleaning log tables (sysssislog and sysdtslog90)
I have a SQL SERVER 2014 standard database and during the monitoring of the database, I realized that I have some SQL tables that are a little large and went to search about. The tables are…
-
2
votes1
answer445
viewsGroup query by similar but non-identical records
I need to migrate a database (from SQL Server for PostgreSQL and I’m creating a ETL interactive in PHP to make this change), which is about 10 years old, about 2 million records in the clientes that…
-
2
votes2
answers1970
viewsPHP error with Sqlserver Exception 'Pdoexception' with message 'SQLSTATE[08001]: [Microsoft][ODBC Driver 11 for SQL Server]
I installed the right driver in PHP, added the extension in php.ini, but when I try to connect with PDO on sqlserver, this error appears: Exception 'Pdoexception' with message 'SQLSTATE[08001]:…
-
2
votes0
answers100
viewsENTITY truncating decimal value when doing SELECT
I have the following situation, When executing a query using LINQ, I get the following return 5178560,00 but if I run the same query, directly in SQL SERVER, it returns me 5179975,00. It’s not a…
-
2
votes1
answer1015
viewsHow to check user on login screen?
I have a problem, I have a login screen and I need to check it with a query Sql. To be able to do something, but she doesn’t check and enter directly. private void btn_Entrar_Click(object sender,…
-
2
votes1
answer38
viewsError when grouping table field
I need to group the data of a SELECT across the countryside a.afo_vch_NmrCtf, because the data is being returned as follows: When I use the GROUP BY the following error is returned : Msg 8120, Level…
-
2
votes1
answer301
viewsCase-sensitive query in sql server with Laravel 5.4
I am making a query to the database (sql server) for user and password validation with Laravel 5.4 but, the query is running as case-insensitive. In the database is: pwd = Aa12a Input: password =…
-
2
votes2
answers1333
viewsSet default value SQL Server column
I would like to know how to set an Insert pattern in a column in SQL. Example: CREATE TABLE XPTO( ID INT IDENTITY(1,1), NOME VARCHAR(100) NOT NULL, ATIVO CHAR(1) NOT NULL) In this case, I want to…
-
2
votes1
answer531
viewsHow to save Image to a specific folder?
I have the following code: protected void btnSalvarDestaque_Click(object sender, EventArgs e) { if (fuFotos.HasFile) { string strname = fuFotos.FileName;…
-
2
votes3
answers92
viewsManipulate String in JAVA?
I have an appointment of SQL that the content brings me so: [email protected];[email protected] I only need the first address, I have to disregard everything from the ;?…
-
2
votes1
answer48
viewsOnly spend a year in a proc of sql server 2014
I made a filter in a PROC of my own and I’m not getting any results. Running proc did not give any error, but it does not bring any result and I do not know if it is correct. The colleague said I…
-
2
votes2
answers441
viewsSystem.Data.Sqlclient.Sqlexception: Conversion failed when Converting the varchar value to int
I’m getting this Exception in c# when I try to read SQL data. I’m wondering if this error is a problem with my SQL or C#. My SQL code that makes the conversion is this: `$ (SELECT ORDEM FROM TABELA…
-
2
votes1
answer763
viewsInsert with two different selects
That one of mine insert is not working. insert into t_cmo_oit1980 (id_oit, id_exm_rea) select max(id_oit) + 1 from t_cmo_oit1980, select id_exm_rea from t_cmo_Exame_Realizado where id_exm = 3936 and…
-
2
votes0
answers18
viewsphp does not display accent with utf-8
I am working with PHP 5.6 and SQL Server. I am working with bootstrap and the database is Latin1_general_ci_as. My HTML is as below: <!DOCTYPE html> <html lang="pt-br"> <head>…
-
2
votes1
answer236
viewsDebug Proc in sql server 2014 database
I use Sql Server 2014. I am having problems with Stored Procedure, because when running with certain filters, it triggers this error: Message 512, Level 16, Status 1, Procedure…
-
2
votes2
answers1894
viewsCreate total sales (value) per customer (SQL)
I need to make a procedure to install the column cli_TotalCompras of the customer table with the total (in value) of the customer’s purchases. On the table vendaProduto have the value…
-
2
votes1
answer567
viewsSQL SERVER EXPRESS 2014 ERROR (Microsoft SQL Server, error 1225)
Good morning, all right guys? Following work with database, and we are having some problems with SQL SERVER 2014 x64, on Windows 10. I am doing the installation normally and changing the network…
-
2
votes2
answers511
viewsProtect SQL Server Database
I have 2 SQL Server databases in my SQL Server Management Studio. I would like to put password in one of the two, making it impossible to access it, is possible?
-
2
votes1
answer298
viewsError trying to insert Datetime.Minvalue into database
I have an object that has a property Datetime and, start with the value of the property Datetime.Minvalue The problem is that, when passing this value to register in the SQL Server database gives an…
-
2
votes1
answer250
viewsError while performing sql server + php + Pdo query
Follows the code: $conexao = new PDO("odbc:Driver={SQL Server};Server=127.0.0.1;Database=MASTERDB; Uid=admin;Pwd=admin123;"); $select = $conexao->query("IF Object_ID('tempDB..#TabBatidas', 'U')…
-
2
votes1
answer1249
viewsFind a numeric group in the string
Hello, I would like a help to locate a group of 20 numbers within a string that has characters and symbols. Let’s say my string has 165 characters, I want the numbers from 127 to 147 that are my…
-
2
votes2
answers2067
viewsOrder change of Sql columns?
Good morning Could you instruct me to change the order of the columns in a table? Example: I have the Table IcmsMvaUF in the following order: I’d like to pass the column MvaEmpresa to come first, to…
-
2
votes1
answer1016
viewsView with parameters without external Where?
I need to receive parameters for a view, but how she got the COUNT(DISTINCT DTA_HOR) I can’t with the where external. Would it have some other way? SELECT EX1 ,EX2, EX3, EX4, (SELECT COUNT(DISTINCT…
-
2
votes2
answers490
viewsHow to save data to SQL database - Submit
I am studying ASP.NET MVC, I am using the Identity to carry out user control and etc. So, I created a page, where the user will enter with 4 information: Mileage Initial; Mileage Final; Quantity of…
-
2
votes3
answers8342
viewsSELECT in a table using NOT EXISTS SQL (SERVER 2012)
I’m trying to make a select tb1 using Where NOT EXISTS (select* tb2) I am trying to select the line in tb1 that does not exist in tb2 to perform an INSERT later. But when testing in select it is not…
-
2
votes3
answers873
viewsDo not return a field value when it is zero
I’m creating a consultation on SQL, but I need a certain field not to display the values when it is zero. It is possible? SELECT gfilial.nomefantasia AS 'Filial', tmov.codtmv AS 'CODTMOV',…
-
2
votes2
answers3352
viewsHow to fix accentuation query sql server data
Good morning! Guys, how do I correct the accents of the data coming from a select in sql server. For some records that were to come as Sergio, is coming SÃ rgio.
-
2
votes1
answer6162
viewsTraverse row by row of a table
I have a temporary table that I fill with the result of a particular query. I need to go through the data of this temporary table, row by row, and take certain fields and insert them into another…
-
2
votes1
answer291
viewsInsert error with FK
I have two tables, Client and Plan, which have the relationship 1:1. I have 3 plans registered in the database with their respective data. But when trying to insert a Customer that has a Foreing Key…
-
2
votes1
answer203
viewsCreate a database backup that is on Azure
I’d like to back up a database on Azure. I tried to backup from Microsoft SQL Server Management Studio, but no backup option appears. I tried to back up the Azure portal, but you don’t have the…
-
2
votes2
answers50
viewsdoubt with query in sql
I have a table with 5 fields: id name office salary date ...and wanted to make a query that returns the name of the people with the highest salary, of each position, and I have for example 3…
-
2
votes1
answer109
viewsMultiquery PHP PDO - SQL Server 2012 - IIS 8.5
Is there a problem with running multiple queries with the same PHP PDO code? Example: <?php // Retorna $con include 'conexao.php'; // Suponhamos que dbo.minha_tabela tenha apenas três campos,…
-
2
votes1
answer139
viewsID of out-of-order tables
I have a table with 9 records, my identities are in order from 1 to 9, when I enter a new record in the table automatically a new ID is set, but it is set with the value 30 instead of the next…
-
2
votes1
answer33
viewsLogin transaction log MSSQL 2012
I need a help, I have to provide a login on MSSQL ERP company and my superior need to monitor transactions of type INSERT, DELETE and UPDATE that are made by them, in case the scripts that were…
-
2
votes1
answer734
viewsHow to represent the Real type in C#?
I have an existing table in a bank of a client of mine and there has an attribute with the data type REAL. Like I do at C#? float or decimal? Which is the best way?…
-
2
votes1
answer637
viewsHow to compare the values of a column with the average of these values in SQL?
I have a column of books, and I just want to show the books that the price is higher than the average of those prices, how to do that? The name of my column is price, and I can’t put a where price…
-
2
votes1
answer105
viewsAdding a Character to a column value
I would like to know whether it is possible to include a character set at the end of a column data. For example: 'Coluna 1- Quantidade |10000 |20000 |15000 |20000 I want to extract a query where I…
-
2
votes0
answers40
viewsRecognition of SQL Server drives for db connection in PHP
I’m having trouble connecting to the SQL Server database. I can’t install the drives to be recognized. On the Internet I’ve tried every kind of thing and nothing has worked. I downloaded the drives…
-
2
votes4
answers1225
viewsHow do I write a store that uses current and previous line values?
I have the following table, # id # dataTmp # referencia #nProduz#nStock # id2 #necessi# # 115237 # 31-01-2017 # VL03280103 # 0 # 0 # 6 # 0 # # 115238 # 01-02-2017 # VL03280103 # 0 # 0 # 7 # 0 # #…
-
2
votes2
answers306
viewsAny ASP.NET MVC solution for SQL injection?
I have in the application a code that validates the data entry, adjusting according to what is necessary, this would be considered a good or a bad option? public static string ValidaDados(string…
-
2
votes2
answers1081
viewsList table with condition ASP.NET MVC
I’m studying ASP.NET MVC5, so I did one Model called 'Reporteriotagmodels' containing: public class RelatorioTagModels { [Key] public int TagID { get; set; } [Required] public string Tag { get; set;…
-
2
votes1
answer131
viewsReturn only part of the SQL field in the query
I wanted to return in the query only the values that are between parentheses in the table field. SELECT F2 FROM [dbo].[Vestcasa_Ranking_Produtos_Custo_] F2 Airtom..(635) paulo victo r.. (234)…
-
2
votes2
answers1290
viewsHow to check Null in a select @Local_variable
To set a default value for a local variable, if the select that should "set" it returns NULL? For example: DECLARE @Minha_Var VARCHAR(70) SELECT @Minha_Var = Nome FROM CLIENTES WHERE Id = 10 This…
-
2
votes0
answers525
viewsAccess SQL Server Express remotely on the Google Cloud Platform
I have a server in GCP and everything is working correctly(IIS, SQL Server...). But I’d like to remotely access a database that’s on that server. I’ve done this procedure before:…
-
2
votes1
answer101
viewsConvert query to Sqlserver
I have the following query for the Oracle bank: select xmlagg(xmlelement(e, d.delinha, '').extract('//text()') order by d.nulinha).getclobval(). I need to convert to run in the Sqlserver bank, but…
-
2
votes2
answers441
viewsHow to select a date in c#?
I intend to select by the current date, like: list all the data that was registered today in my table, I did this way and does not result in anything, does not generate errors or list any of the…
-
2
votes1
answer80
viewsCase Sqlserver, how to proceed?
I am trying to display a column q is set at 0 and 1 so that when by 0 show 'Ok' and for when it is 1 'NOK'. Follow my code that is not working, but by the query slq String query1 = "Select…
sql-serverasked 7 years ago Lucas16 65 -
2
votes1
answer200
viewsSQL - Search for the names of patients who had more appointments in January 2016
Hello, I would like to know how to do this consultation: "Find the name of the patients who had more appointments in January 2016". select * from PACIENTES select * from CONSULTAS These are the…
-
2
votes1
answer33
viewsSqldatareader Incompatible Databindtable does not implement Ienumerable
I have a problem showing the data of a column on sqlserver, to insert as x and y in my Chart in Asp.net. The problem is this, it seems the method (DataBindTable) is waiting for IEnumerable but my…
-
2
votes1
answer65
viewsHow to make a select that brings the data registered in a given week?
I intend to list all the data registered in a given week, someone can help me? I did something similar to the example below and it doesn’t work. public List<View_Venda> Venda_Semanais() {…