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
-
4
votes1
answer145
viewsTrigger without replicating data - SQL Server 2012
Guys, I have a Trigger in the FRM_46 table that would replicate the data right after the Insert or update to the FRM_31 table, however, it is not replicating, I already analyzed and made the tests,…
-
4
votes2
answers8557
viewsHow to run the INSERT script with one million lines in SSMS?
I’m trying to run a script on SQL Server Management Studio (SSMS) with more than 1 million records and the following error occurs: Message 10738, Level 15, State 1, Line 1032 The number of line…
sql-serverasked 7 years ago hard123 2,329 -
4
votes6
answers6000
viewsHow to get the column properties of a table?
I am working with a table created by another person, and there is in it a field of CPF, would like to know what is the size of this field, how many characters it is able to support. I know that in…
-
4
votes3
answers485
viewsAid in SELECT DISTINCT
I have the following select: SELECT CD_CLIENTE, DT_ATUALIZACAO, FROM TABELA Return me the following result: But I’d like to select just the last DT_ATUALIZAÇÃO of each customer, I thought to use a…
-
4
votes2
answers1851
viewsWhat is the problem of using [n]varchar(max)?
Why the practice of using [n]varchar(max) can cause problems? In my scripts whenever I don’t really know what the length of a string and to prevent problems, I have used nvarchar(max). A few days…
-
4
votes3
answers1332
viewsFormat DATETIME SQL Server
I wonder if you have any way to change the Datetime format in SQL Server EX: 2019-07-09 11:42:00 for 09-07-2019 11:42:00
-
4
votes1
answer93
viewsData Cleanup - SQL Server
I’m working with a column of phones, but some lines have two phones separated by ";". 99999999 ; 99999222 12345678 ; 87654321 40028922 123123456 ; 1122334455 My goal is to put duplicate phones on…
-
4
votes1
answer212
viewsEntity Framework Query Many to Many
I’m starting to use the Entity Framework and I’m looking to make a query between two tables, Livroes and Autors, and their relationship is like Many to Many. I don’t know if it’s relevant but I’m…
-
4
votes1
answer1240
viewsConvert Unix Timestamp to Datetime
I am trying to select the largest date from my table, however the dates are stored in Unix Timestamp format in a whole column type. I need to do this conversion because I need to calculate the…
-
4
votes1
answer68
viewsDifference between query with and without Inner Join
What is the difference between doing the two queries below, one with and the other without INNER JOIN? What is the most appropriate? SELECT p.Descricao as Produto, c.Descricao as Categoria FROM…
-
4
votes1
answer219
viewsQuery Return - Generic Entity Framework Repository
I have a generic repository and I realized that it is taking too long to return a query with the selection of some columns of my database, the Query() method is as follows: public IList<T>…
-
4
votes2
answers229
viewsSQL Maximum value of another table
I am doing a project of the course and I stopped at the last step and I would like a little help from you.. The project is an SQL database with "leasing" (contract for "rental" of cars.) The tables…
-
4
votes1
answer106
viewsData Manipulation
I wonder if it is possible, after converting the date and bringing only the time, to manipulate this result to return the closed time. The example below details better. CONVERT(VARCHAR(19),…
-
4
votes1
answer2755
viewsGROUP BY in query with column by subquery
I have the following select: SELECT A.CARRO, (SELECT TOP 1 VALOR FROM tab2 B WHERE B.DATA <= A.DATA ORDER BY B.DATA DESC) VALOR FROM tab1 A In (SELECT TOP 1 VALOR FROM tab2 B WHERE B.DATA <=…
-
4
votes1
answer385
viewsHow to PIVOT a column by concatenating strings into Sqlserver
Hello, I’m making a query in a database to identify all the columns that are primary key's of the tables of a database and also identify whether or not they are identity. For this I use the query…
-
4
votes2
answers404
viewsQuery with Datetime Sql and C#
I’m trying to get you to return to me the patient of a particular day and time in command next: SqlCommand cmdSelect = new SqlCommand("select DISTINCT P.nome,P.codPaciente, M.codMedico, C.descricao…
-
4
votes1
answer69
viewsParameters for encrypted columns
I am trying to create a database to save a user’s data to the SQL SERVER database, but the table has columns encrypted with Always Encrypted, resulting in a conflict error. I have tried to change…
-
4
votes1
answer128
viewsHow to insert records via cursor?
I need to insert unique records by a field that has the unique identifier, so I’m using cursor; however, the unique identifier does not add according to the inserts. ERROR: You are duplicating and…
-
4
votes1
answer332
viewsCompare data from two SQL Server tables
Good night, I am studying SQL queries and I came across a problem in a query, I have two tables: Table: Products +----------------+--------------+--------+ | Codigo | Produto | Valor |…
-
4
votes1
answer75
viewsDoubt query in SQL Server - Information Association
My friends, good night! I need to perform a query in a database using SQL Server and I got stuck in a problem so I ask, please help from you. Here is an example summary of the problem: I have a…
-
4
votes1
answer578
viewsHow to generate a subquery in Line/EF
Hello, everybody. I have a situation, where I concatenate some subquerys Sqls that are concatenated into other Sqls queries, to return some values. I have several functions like these, because I use…
sql-server entity-framework linq linq-to-entities linq-to-sqlasked 5 years, 9 months ago Fabiano Richetti 41 -
4
votes3
answers1018
viewsConvert to date type 'yyyy-mm-dd'
I have a problem trying to modify the type of date that appears to me in two columns of a table of mine. This is my code: declare @top10reclamacoes varchar(max) declare @html varchar(max) declare…
-
4
votes3
answers98
viewsSort select displaying something at the end after sorting
I have a table called Tabela1 and another call Tabela2: Tabela 1 Tabela2 Indice, pessoa_id sts, pessoa_id The index goes from 0 to 10, and sts can be ON-LINE, OFF-LINE OR ON-LINE-PAUSADO. I wish…
-
4
votes3
answers214
viewsError: "Return should not be followed by an object expression"
I have this function that has a simple registration but is not registering My doubt would be on that return RES; which gives the error message below the code. //botao para cadastrar OS private void…
-
3
votes2
answers2614
viewsHow to get the index creation date in SQL Server?
By SQL Server Management Studio I did not find in the properties of an index its creation date. How can I get the creation date of a specific index by just referring by name?
-
3
votes3
answers2054
viewsProtect the connection string in a . NET Winforms application?
I have an app .NET Windows Forms connecting to a server SQL Server directly, without the use of an intermediate layer as a Webservice or Webapi, through SqlConnection. This application is installed…
-
3
votes1
answer2098
viewsInsert SQL Server records via ftp file.txt
I have the following structure in a file . txt of an FTP server: CodigoPedido: 120952 DataPedido: 2014-03-11-10:19 LocalVenda: MERCADO LIVRE Status: A ENVIAR Parceiro: 0 IdCliente: 103002…
-
3
votes5
answers2467
viewsIs it feasible to define mandatory fields in the application instead of the database?
I came across a system where most of the mandatory field rules are done in the application and not in the database (with the exception of the primary key). As I have no experience with many systems,…
-
3
votes1
answer1426
viewsTrigger UPDATE write TXT file
How can I create a Rigger that is fired every time I have one UPDATE in x column, grab the new value create new txt file and insert inside it. ( for synchronization purposes ). For example: produtos…
-
3
votes1
answer13631
viewsHow to change the date format in SQL Server 2008?
Currently my seat is in YYYY-DD-MM format I would like to put in MM-DD-YYYY. I found the SET DATEFORMAT only it’s not the best option since I’ll have to add it to all the querys. Is it possible to…
-
3
votes3
answers3330
viewsGrab ID immediately after insertion
Entity and LINQ usage. I would like to know how I get a generated ID right after entering a record, before anyone else can enter it as well, that is, ensure that that ID is the one generated by me.…
-
3
votes1
answer475
views"Linked Server" with Mysql
DBMS: SQL SERVER 2014 + Mysql 5.5 What are the syntax of SELECT, INSERT and UPDATE instead of using the "OPENQUERY" function, when connecting through the SQL SERVER Linked Server, connecting in…
-
3
votes2
answers10109
viewsSet Value Local SQL Server Variable
I would like to assign the value of the local variable within the SELECT, as in the example below, but displays the following error message: "A SELECT statement that assigns a value to a variable…
-
3
votes3
answers944
viewsPHP and Sqlserver connection
I’m trying to make a connection to Sqlserver and PHP But the page returns me the following error: Warning: mssql_connect() [Function.mssql-connect]: Unable to connect to server: 192.168.2.7 SRVDOC…
-
3
votes1
answer2694
viewsConnection to the database with App.config
How to establish a connection to the Northwind database using App.config and ADO.NET?
-
3
votes1
answer4362
viewsQuery to the C# mvc database
How is the syntax or how do I transform a query with multiple joins to a search in my application in c#Asp.net mvc? Example: I have a form with the following controller public ActionResult…
-
3
votes1
answer1251
viewsFree external access in sql server 2014
I have a machine on Amazon, and sql server is installed but I can’t access from outside the server. I wonder if there are any settings besides releasing the protocol in Security group.
-
3
votes1
answer101
viewsUser Defined Table Types between different databases
I created a User Defined Table Type in a DB1 database. Trying to declare such a variable in a BD2 database procedure gives me the following error: The type name 'BLABLA' contains more than the…
sql-serverasked 10 years, 2 months ago user14575 31 -
3
votes3
answers230
viewsSQL Query export for excel
Good, I’m having some difficulties in the result of a query. To fit you is the following, I have a registration application of "unavailability." and I need the following: Every day I have to extract…
-
3
votes0
answers71
viewsHow to use @sqlstatement in SQL Server
As I can make better use of the @sqlstatement variable in SQL Server, I couldn’t understand what its real function is. Please explain to me and leave some examples? I ask that if possible do not use…
sql-serverasked 10 years, 1 month ago Jean Braz 187 -
3
votes1
answer1261
viewsHow do I show the result of an SQLSRV query in PHP?
I need to do a calculation via sqlsrv, add a column of values. This is the code I tried to make: $qryAC = "SELECT SUM(VLRECEITACONT) AS receitaConta FROM [RDO].[dbo].[ANALISE_CRITICA] WHERE…
-
3
votes1
answer1161
viewsPermission to create a database denied by the master database
I am trying to migrate the database created automatically by Identity to control user authentication and this error appears: CREATE DATABASE permission denied in database 'master'. My string…
asp.net-mvc sql-server entity-framework asp.net-identityasked 10 years, 1 month ago Sydinho Franco 103 -
3
votes1
answer187
viewsCubes of some customers in Analysis Services
I intend to allow my customers to access their data to generate customized reports and use the power of Powerpivot Excel. Today all customers (business) are in the same database and for the little I…
-
3
votes2
answers106
viewsObject Variable type and Expressions
I wonder if you have any way to mount an Xpression on ssis that returns true or false on a variable of type Object : basically would be something like in sql 12 in (14,25,45,12,54) but in Expression…
-
3
votes1
answer3273
viewsOnline SQL database for LOCAL NETWORK only, connect via c#
I developed a system for my company and need a database hosted on our internal network, explaining better I want to host this database on a PC running a Windows Server 2012 here in the company, our…
-
3
votes1
answer677
viewsProblem storing decimal values in SQL Server
I have a decimal field (18, 3) and in the application I use a Javascript plugin to format the entered values, so I pass the value so SQL Server 45.000.000.000, when I look at what was registered was…
-
3
votes1
answer18490
viewsAdd Column in SQL server
I’m working on a system that I need to realize a sum that will be made into a view SQL Server. In C# I know how to resolve this. I would like to resolve using SQL. ColA ColB 200911 1634,50 200911…
-
3
votes1
answer144
viewsDisplay subquery result and use it for calculation
I need to present a result of a subquery and use the same result to perform a calculation, is it possible to play it for a variable in MS SQL 2008 or something like that? example: SELECT @test =…
-
3
votes3
answers563
viewsProblems with LEFT JOIN
I’ve been racking my brain for a few days with SQL on something that should be very simple, but I can’t fix it. I want to get all data from the table [Numorder] including those not in the table…
-
3
votes1
answer1433
viewsProblems with NOLOCK, READ COMMITTED SNAPSHOT
I always see sqls mounted with WITH NOLOCK that say improve performance, but I’ve also heard that NOLOCK is obsolete and what should be used now is READ COMMITTED SNAPSHOT, in this scenario my…