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
-
7
votes1
answer2296
viewsRounding as a result of multiplication
I have this scenario: - multiply by 2 values which will be rounded to 2 boxes for the table to be inserted. Follow the example: CREATE TABLE #TMP ( A DECIMAL(23,6), B DECIMAL(28,2) ) INSERT INTO…
-
7
votes2
answers2252
viewsSelecting a value from a Listview row/column populated by LINQ to SQL
Through the double click event I need to pull a value from a row/column in a Listvview populated by LINQ to SQL. For example, when the user needs to select a value from a row/column of this…
-
7
votes1
answer1294
viewsPhonetic search on SQL server
I need to implement phonetic search for Portuguese (br). Does anyone have any phonetic search solution in SQL Server with c#? The search should search inside a string using the SOUNDEX function or a…
-
7
votes3
answers280
viewsLog tables should have Foreign Keys?
I had a case in my service these days when it was not possible to delete a record because it was referenced by the table of log. Logically what generated a call for the IT area to solve. But that…
-
7
votes1
answer482
viewsReturn last value inserted in table where value is not Identity?
I would like to return the last value of the primary key entered in the table, but my primary key is CPF so I can’t use SELECT SCOPE_IDENTITY().
-
7
votes1
answer4174
viewsHow to concatenate lines?
How to concatenate all the results of a query in SQL Server in order to return all information in one variable? For example, considering a table cliente with the following composition:…
-
7
votes3
answers12428
viewsWhat’s the difference between Cast and Convert?
In a Transact-SQL (Ramalho Series) book it is said: CAST AND CONVERT It implicitly converts one expression of data types to another. CAST is synonymous with CONVERT. What do you mean by CAST is…
-
7
votes1
answer3980
viewsIn which cases return the System Exception error.Outofmemoryexception
Which are the most frequent cases that can return this Exception?
-
7
votes2
answers74
viewsWhat is the best type to store area, volume, perimeter?
Decimal, Numeric or Float. What is the best option for storing area or volume? I would use Decimal, but I would like to see the opinion of others as well. I guess not, but the right guy or the next…
-
7
votes2
answers441
viewsQuery that returns if the child has inherited the parent’s and/or mother’s surname
I have a scenario that I need to sort my records where: The child inherited the surname of the father and/or his mother? Note in the image that if one of the child’s surnames exists in the parent’s…
-
7
votes2
answers4291
viewsDifference between date and datetime
I was researching the type of data SQL SERVER and I came across this table What would be the real difference between date and datetime data? Time, minute, second notation only ? What would that…
-
7
votes3
answers6315
viewsHow to make an "Insert" with Dapper using a class?
I’m testing Dapper and when I try to use a class I found the error: Must declare the scalar variable Follows the code: public class Teste { public int id; public string nome; public int idade; }…
-
7
votes1
answer1004
viewsHow to simulate load in a database?
I have an SQL Server database that recently had performance problems in production by the large amount of simultaneous users added to some implementation and architecture problems. After taking some…
-
7
votes1
answer16562
viewsRegex inside SQL Server
How to recover fields with the following pattern? a111/1111 or a111_1111 or a111-1111 or a111+1111 where: a = some letter of the alphabet; 1 = any digit of 1-9; I rode a Regex that is working…
-
7
votes1
answer94
viewsSQL Server JOINS vs Subquerys
I was making some queries, and came the need to carry out the grouping of a table that was in a JOIN within the query. To illustrate. Sales chart. +----+---------+------------+----------+ | Id |…
-
6
votes1
answer1212
viewsIs it possible to create a Rigger that invokes a web service?
I am working on the integration of two databases. It is a system that needs the status of employees in HR. For performance reasons, I can not point out all queries that depend on employees for the…
sql sql-server web-service integrationasked 10 years, 10 months ago Guilherme de Jesus Santos 6,566 -
6
votes2
answers4039
viewsWhy use Bytes instead of Image? What is the best practice?
I would like to know why to use the data type Bytes instead of using one’s own Image. If the SQL Server database has the Image data type, then it should be easier and more practical to enter in mode…
-
6
votes2
answers652
viewsI cannot place a subquery inside the IN in the PIVOT
Below is the code for table creation and insertion of some data for test. CREATE TABLE [dbo].[tb_empresas]( [data] [date] NULL, [nome] [varchar](100) NULL, [valor] [decimal](18, 2) NULL ) ON…
-
6
votes2
answers26381
viewsProblem connecting to SQL Server 2012 database on IIS
I cannot run my system queries on IIS, when running in Visual Studio I can get the result easily. The mistake I get when I try to do something is this::…
-
6
votes2
answers345
viewsSQL Server 2005 and line version control
In my current scenario, every Friday, I need to list all rows of a table that have been added or changed. In this table we have a field DataDeInclusao which obviously receives the date of inclusion…
-
6
votes4
answers2718
viewsGenerate sequential Ids without losing the sequence
For Identity do not want, because it breaks the sequence if something happens. Max() + 1, I find it very vulnerable and slow when you have a lot of records. So I ask you, is there a way that someone…
-
6
votes1
answer999
viewsClient installation of SQL Server
I developed an application in C#, which uses SQL Server Express 2012. No development everything went well with access to the database because it is all on the same machine ( utilizo o localhost).…
-
6
votes2
answers1124
viewsWhen is it worth paying for Sqlserver or Oracle?
Databases open-source how Mysql and Postgres are so advanced that they can serve a wide variety of applications smoothly, perhaps most. (There’s Sqlite too, but this is more for when portability is…
-
6
votes0
answers152
viewsIssue of permission to install Mediawiki on Sql Server
I am having problems trying to install Mediawiki using Sql Server. The following error occurs: [SQLSTATE 42000][Error Code 2760][Microsoft][SQL Server Native Client 11.0][SQL Server]The specified…
sql-serverasked 10 years, 4 months ago Andre Figueiredo 5,030 -
6
votes1
answer2137
viewsHow to optimize this query query with other sub-consultations?
I have a query query that is taking too long to run (almost 2min) and need to optimize it: select Cidade.Id as CidadeId, Cidade.Nome as CidadeNome, Cargo.Descricao as CargoDescricao, '{0}' as Grupo,…
-
6
votes1
answer967
viewsMonitor space in sqlserver datafile
Usually I don’t let the databases grow automatically up to the disk boundary. Therefore, I would like to know if colleagues have any Procedure so that I can monitor and be alerted of when the space…
sql-serverasked 10 years ago Jean Braz 187 -
6
votes1
answer4622
viewsSQL increasing ID by 1000 units
I have a database in SQL Express with a reasonable amount of data for over a year. Everything always worked well, but now is presenting the following problem: certain times the ID in some tables…
-
6
votes2
answers335
viewsProblem retrieving inserted id
I created a register with some 58 data. As I was creating, I was testing and the data was entering the BD, and every time an insertion was made, I took the id of the last data set/group inserted.…
-
6
votes1
answer474
viewsHow to make a query that returns data from the last 7 days without considering Sunday
I need some condition in SQL SERVER return the result of the list of elements taking into account the last 7 days of creation of the same. But he cannot consider Sunday as a valid day in the…
-
6
votes2
answers6106
viewsMysql group_concat() in Sqlserver
I created a table for example: I have the following content: select * from table_t; And I need to get the following result: In Mysql I use the following query: select group_concat(concat_ws(' -…
-
6
votes5
answers10525
viewsShow every day between two dates
I need to display all dates that exist between two set dates. I do not need the information of the difference between these dates, nor the data that are in the interval between them, but show the…
-
6
votes1
answer781
viewsConnection pool with ADO.NET and Sqlconnection Dispose, what is correct to do?
I asked a question yesterday about What is the difference between Idisposable implementations? I was implementing a class to help obtain instances of SqlConnection, SqlCommand, SqlDataReader methods…
-
6
votes1
answer2951
viewsLEFT JOIN using Linq
I have the following tables: Responsavel | Filho Id Nome | Id Nome ResponsavelId 1 Ana | 1 Aninha 1 2 Maria | 2 Ana Júlia 1 3 Pedro | 3 Mariazinha 2 I’d like to make a SELECT with INNER JOIN where…
-
6
votes1
answer1038
viewsCouldn’t perform the Edit because Another user changed the record
Does anyone know if there is any trace of a table that is dropped from a bank? To make it easier if it’s recreated, for example, and when I say vestige is in the bowels of the bank itself. I’m going…
-
6
votes4
answers11049
viewsHow to select in 3 tables?
I need to do SELECT in two tables with relationship n for n, soon, I will have to make use of the intermediate table as well, but I don’t know how to do it. I am using PHP and Sqlserver database.…
-
6
votes2
answers1494
viewsDelete record with duplicate (Id) leaving only one occurrence
This is an old bank, dbase who was transferred to MSSQL. How to leave only one occurrence in the case of id duplicated in a table? | Id| Nome | |-----------| | 1 | JOSE | | 1 | JOSE | | 2 | MARIA |…
-
6
votes4
answers268
viewsBETWEEN demands arguments in ascending order? Why?
I have the following dummy table. I created the following query: SELECT * FROM ALUNOS WHERE IDADE BETWEEN 10 AND 15 Students A, C and D return. Now, because when I invert the order in the BETWEEN…
-
6
votes0
answers2043
viewsWork with two databases in Laravel
I’m creating an application that needs to connect to two different databases. A database I am creating (Mysql) and a database I received ready that I am only allowed to query (SQL Server). The…
-
6
votes4
answers5546
viewsSQL query to get all records from last month but until the current day
Good morning, I need to know a percent variation of last month’s job records for the task logs you did this month. For this I need to compare with the current day, for example. If today were…
-
6
votes1
answer149
viewsWhy does OFF SET slow down SQL?
I have the following SQL, generated by Entity Framework 6. SELECT [Project1].[C1] AS [C1], [Project1].[ID] AS [ID], [Project1].[CAMPO1] AS [CAMPO1], [Project1].[CAMPO2] AS [CAMPO2],…
-
6
votes1
answer1709
viewsWhat’s the difference and benefits of using @@IDENTITY and OUTPUT INSERTED.ID
I’ve always used the @@IDENTITY to get the last inserted identity value, as in the example below. create Proc [dbo].[Arquivos] @IdArquivo int, @IdArquivo_Out int output as begin Set Xact_Abort on…
-
6
votes3
answers62099
viewszero to left (LPAD) in Sql Server
How is done in Sqlserver so that the result comes with zero left ? in mysql would look like this: select lpad(mes,2,0 ) as 'mes', ano from tab_qualquer; How does something equivalent in Sql Server?…
sql-serverasked 8 years, 8 months ago SneepS NinjA 7,691 -
6
votes2
answers737
viewsConcatenate fields in a more performative way
I am concatenating the description lines of a record so that instead of having N records for a description it has only one. I can make it happen, but I wanted a more performative way, because I’m…
-
6
votes1
answer1911
viewsMaximum size for database tables
What can be the maximum size that a table can have? To make it clearer: a table in Mysql, what is the maximum size it supports? And in SQL Server, Oracle, Postgresql?
-
6
votes1
answer1328
viewsHow to restrict dates in Mysql and SQL Server?
I wonder if I can restrict certain dates in the database itself, not in the code. For example, I have a table that records date of entry and date of exit. Here are some requirements. The date of…
-
6
votes3
answers23959
viewsDisable SQL Server Column Identity
How do I disable the property identity of a column in the SQL Server? I’ve tried to: SET IDENTITY_INSERT ON/OFF But it didn’t work. I don’t know if it’s only for insertion, but I need to do an…
-
6
votes2
answers323
viewsShow command executed when SQL error occurs
Considering the following command executed BEGIN TRY -- Generate a divide-by-zero error. SELECT 1/0; END TRY BEGIN CATCH SELECT ERROR_NUMBER() AS ErrorNumber ,ERROR_SEVERITY() AS ErrorSeverity…
-
6
votes3
answers324
views"Translate" query from Mysql to SQL Server 2012
What is the SQL Server 2012 query that corresponds to the next Mysql query? REPLACE INTO schedule SET jobname = "sqldump" , last_exec_date = NOW()…
-
6
votes1
answer232
viewsUser who has permission to create other SQL Server users
I’m trying to use a user other than SA to create new users on an SQL Server 2014 basis, I’ve tried the roles db_accessadmin and db_securityadmin, but they do not give permissions to change other…
-
6
votes1
answer155
viewsModeling with Code First so you can exchange databases
If I generate my database for Mysql using the concept of Code First is it possible to change it to SQL Server in the future with relative ease? Need to change the classes or just the config and the…