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
-
82
votes7
answers21276
viewsBest kind of data to work with money?
I am developing a project for commercial automation, using PAF-ECF and everything else. Would Aual be the best type of data to work with SQL Server and C# for money issues? Mainly in relation to…
-
39
votes1
answer20752
viewsIs it possible to do an UPDATE with data from another table?
I know it’s possible to execute one INSERT with data from another table: INSERT INTO Tabela (Col01, Col02, Col03) SELECT Col01, Col02, Col03 FROM Outra_tabela WHERE Condicao = 'qualquer coisa' But…
-
34
votes1
answer33629
viewsWhat is the difference between ISNULL and COALESCE in a survey?
I’m having second thoughts about using the ISNULL and COALESCE. Currently creating a query in SQL Server, I was left with doubt about ISNULL and COALESCE, I did some research and I was able to find…
-
33
votes8
answers48170
viewsHow to calculate a person’s age in SQL Server?
Suppose the table Pessoa and the countryside DataNascimento. In an SQL query, what is the best way to calculate a person’s age in integer format in the T-SQL language of SQL Server?…
-
33
votes4
answers5507
viewsWhy are NULL values not selected?
When making a select, I noticed that the data with field NULL are not recovered using the operator<>. Why does this happen? NULL is equal to a char N? See that in the query below only the…
-
32
votes5
answers41630
viewsMysql Limit Equivalent in SQL Server
Someone knows how to relate the differences between Mysql and SQL Server, including using LIMIT n,n? Or if you have a link that lists the differences would be nice. Example SELECT * FROM tabela…
-
29
votes2
answers48751
viewsWhat are Begin, Commit and Rollback transactions?
What are Begin, Commit, and Rollback Transactions? And how to use them? Example in practice will help a lot in understanding.
-
25
votes6
answers17379
viewsHow to improve reading performance of a SQL Server database?
I have a database with more than 250 tables, there are tables with more than millions of records and when I need to search or change some of these records, it takes a lot of time, which ends up…
-
22
votes3
answers12225
viewsWhat is deadlock in SQL Server?
I am trying to solve a problem with an error in SQL Server and seeing a question in the OS, in the reply is quoted a possible 'deadlock' in SQL Server. What is this?…
sql-serverasked 9 years, 6 months ago William Pereira 3,998 -
22
votes2
answers19395
viewsWhat’s the difference between varchar and nvarchar?
What’s the difference between using data types varchar and nvarchar? nvarchar exists in every SQL database? Is there any significant difference in performance between the two? There is a criterion…
database sql-server string typing character-encodingasked 7 years, 5 months ago UzumakiArtanis 9,534 -
22
votes3
answers29017
viewsWhat is ROW_NUMBER?
What is ROW_NUMBER used in the sql server? How and where we should use it? Has a simple example of use ?
-
21
votes3
answers23896
viewsDifference between type text and type varchar in SQL Server
What’s the difference of using text instead of type varchar to store information in the database? Is there a performance problem? Because I have a table in the database that has a column text and…
-
21
votes2
answers48433
viewsUsing WITH AS command in Sql Server
I have seen this example below, I would like to know how this command With [name] AS works on Sql Server, and what are its uses compared to tables in memory or SubQueries, in terms of performance.…
sql-serverasked 9 years, 1 month ago Roger Oliveira 682 -
21
votes1
answer1658
viewsHow to document SQL code?
When I write R codes, the correct way to document is in the code itself, in the form of comments initiated with a special marking #'. #' Add together two numbers. #' #' @param x A number. #' @param…
-
21
votes3
answers2676
viewsWhen to use SET and SELECT?
I know that as in virtually all issues related to "either" there must be situations where it is best to use SET or SELECT, in a Procedure (for example). At work we always wear the same SELECT, even…
-
19
votes1
answer11373
viewsHow to use a specific index in a SQL Server query?
I have a non-standard table in SQL Server installed on my PC which is fed monthly by Integration Services (SSIS) from a report in an Excel spreadsheet. I mean, I’m keeping track of a certain report.…
-
17
votes2
answers40729
viewsDifference between CROSS APPLY and OUTER APPLY?
What’s the difference between CROSS APPLY and OUTER APPLY? How do they work? In what situation can they be used? It would be possible to show some examples?
-
17
votes3
answers960
viewsHow to find a String from Regular Expressions
I have a field in the SQL Server 2014 database that stores the client address. The problem is that everything is stored in a single field varchar. Here are some real examples: Antonio José Nerchis…
-
17
votes3
answers1699
viewsWhy doesn’t "= NULL" work?
In the SQL Server, by fetching all records with a given field with value NULL, if I do so no record is returned: SELECT * FROM clientes cli WHERE cli.cpf = NULL But if you use the following syntax:…
-
16
votes2
answers15027
viewsHow can I refer to the heaviest queries in SQL Server?
In the SQL Server database, how is it possible to know which queries have consumed the most resources of the database in its execution?
-
16
votes2
answers2309
viewsDifference in Indice Unique and Unique Constraint usage in Sql Server?
I would like to know the behavior/differences between a Indice Unique and Unique Constraints to the Sql Server ? Many may think that it makes no difference in the database, but it does! And not only…
-
15
votes2
answers1106
viewsUsing Laravel 4 with Microsoft SQL Server 2008
I need to connect a database SQL Server 2008 in Laravel 4. I have been researching and I did not find solution for the scenario in which I am. I’m using Laravel using the XAMPP (PHP 5.5.6…
-
15
votes5
answers29661
viewsHow do I know if a column exists in an SQL Server table?
I am trying to add a new column to an SQL Server table, and I want to know if it already exists or not. I have tried something like this: IF EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE…
-
15
votes3
answers2752
viewsWhat are indexes in SQL Server for?
For what the index serves, I know it improves performance, but what the database does behind that improves this performance. When is it recommended to use? And where should I use an index?
-
15
votes4
answers6318
viewsHow to display combobox-related value in the textbox?
I am doing a project in C# and SQL Server, and I need the item selected in the combo to display the corresponding values in a textbox. Follow the codes I’ve tried: private void…
-
15
votes3
answers15156
viewsList all triggers in SQL Server
Is there any command, that lists all the triggers from a database in SQL Server?
-
15
votes3
answers4552
viewsUse VARCHAR(255) for all fields or choose the best size for each field?
Assuming the following fields (for example): Nome, Rua, Cidade ,UF. The Nome would be the client’s name. There are people with 2 short names or people with 5 or more names, so it is possible to have…
-
14
votes6
answers14419
viewsWhich database should I use in a small desktop application?
I read a bit about the Meta and I thought that this question does not escape much from the current rules of the site. Risking losing reputation, come on: At the moment I work in a small company that…
-
14
votes1
answer41651
viewsFormat value with Brazilian currency mask
I have a stored trial that returns a credit amount for a certain consortium quota. The return of that value would be like this: 167900. But it should be so: R$ 167.900,00. This value I feed a…
-
14
votes3
answers18167
viewsPDO Drivers for SQL Server
I am trying to run a PHP application (version 5.5.8) with connection to SQL Server database with PDO, but returns the following error: could not find driver I’ve tried enabling features in php.ini…
-
14
votes2
answers352
viewsWhat does the operator = mean in C#?
I have a function in C#, where I decrypt a string and need to convert into a function in SQL Server for technicians to be able to work with the decrypted value. There is a foreach, I don’t…
-
14
votes1
answer16891
viewsWhat does COLLATE LATIN1_GENERAL_CS_AI do?
I’m asking this question because I came across this reply by @Sorack; I didn’t understand what influence COLLATE LATIN1_GENERAL_CS_AI had the result, I’ve seen some answers here on Stackoverflow and…
-
13
votes1
answer7485
viewsLaravel 5 and Sql Server
I need a help, I made several attempts to connect Laravel with SQL Server and all without success. However, I managed to make it work with pure php, using sqlsrv_connect and Code Igniter. Windows 10…
-
13
votes2
answers2784
viewsWhat is the argument limit of the IN operator in SQL Server?
In Oracle are 1000 arguments, which limit in SQL Server?
-
13
votes2
answers722
viewsHow index selectivity works
Reading about indexes I recently came across the term "selectivity". Some places said more selective fields should come first on the index, others say no or that it depends. I have the following…
-
12
votes1
answer398
viewsWhy does the SQL language vary from DBMS to DBMS?
I was used to using SQL for Web projects, always using Mysql. One day I had to write a C++ program that used databases. At first I chose Sqlite but needed other computers in the network to connect…
-
11
votes3
answers1559
viewsHow to condition the insertion of a record in SQL Server?
How can I condition the insertion of a record in a table in SQL Server using the T-SQL language considering the following rules: If the record to be inserted already exists in the table, only update…
-
11
votes5
answers64148
viewsDifference between two dates in days, hours, minutes and seconds
Problem: How to subtract between two dates and return the value in Days, Hours, Minutes and Seconds in an SQL query with SQL Server 2014? Example: Dados: DataRecebimento DataEnvio 2013-11-29…
-
11
votes3
answers175
viewsWhat is the most correct way to make a query with LINQ?
I am trying to make a LINQ query in my BD SQL Server, but the result of it always comes 'null'. I need the first user ID I query. This is the way I try to consult: public decimal…
-
11
votes4
answers16866
viewsHow to know which DATETIME format is used in a given column of SQL Server?
I have a table on SQL Server and one of the camps was created as DATETIME. How should I know query or SQL Server Studio, what format default used of this DATETIME in my SQL Server?…
-
11
votes1
answer3723
viewsMethods Executereader(), Executenonquery() and Executescalar(), what are the differences and how to use them?
I’m working with a database SQL Server in C#, but I noticed that the object SqlCommand has several methods to execute a query, are they: ExecuteReader(), ExecuteNonQuery() and ExecuteScalar(). My…
-
11
votes1
answer3203
viewsLeft Join or Not Exists
I needed to retrieve information that was in a certain table, but were not in another one. Searching found that NOT EXISTS would serve this case, but I saw that Left Join brings the same result: NOT…
-
11
votes2
answers14208
viewsWhen to use WITH (NOLOCK)?
Select * from MinhaTabela with (NOLOCK) I know colleagues who always insert the clause With (NOLOCK) in their selects and I know others who preach that NOLOCK is bad practice and should never be…
-
11
votes1
answer8640
viewsLimit and Offset for Web Paging in SQL Server
I am working with PHP and have about 8000 records currently on DB. As it is for a web page, I need to make a pagination to be able to read the data. From what I understand, I have to do something…
-
10
votes1
answer1361
viewsHow do I use Freetds with MAMP on Mac OS?
I need to use the methods mssql_ of PHP and have always done so using the Freetds in the native Apache of MAC OS. What happens is that right after you upgrade to the OS X 10.9 (Mavericks) I started…
-
10
votes4
answers40379
viewsHow to replace column text in SQL Server (tsql)?
I have a text column in SQL Server 2008 R2, which is filled with wrong typed text, in thousands of records. I would like to make a UPDATE replacing the wrong text with the correct one.…
-
10
votes3
answers1631
viewsConcurrency control in database insertion
I have a competition control problem in entering data from a table. The scenario is as follows:: There is a table that records daily data according to user requests, and this data cannot be…
-
10
votes2
answers49607
viewsHow to format a Datetime field in Brazilian dd/MM/yyyy format?
I would like to format the fields DataAfr and DataTrm of the kind DATETIME, in the Brazilian date format dd/MM/YYYY instead of the American format yyyy-mm-dd hh:mm:ss SELECT e.NmrCnt AS [Contrato]…
-
10
votes2
answers1078
viewsIncrease timeout of dblib connection with PDO
On a connection to an external server (MS SQL SERVER), from another system with which I integrate some data, it is extremely slow, and with that the connection with the database gives error. How to…
-
10
votes3
answers8992
viewsSelect first record within a segmentation in SQL Server
I have the following example table: The consultation asks me to show which students entered first in each course. I can tell which student entered the university first, using the function top(1),…