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
answer227
viewsError updating a table. (Duplicate key)
Good. When doing the update give me error.. Yes ja la I have a record in the table with those values, but when changing the type should not let me do?…
-
2
votes1
answer469
viewsWhat are the differences between Stored Procedures and Functions within Sql Server?
This is a question in a certain academic way, but I have come up with the question. What are the differences between one and the other? What I should consider to choose each case in certain…
-
2
votes1
answer194
viewsHow to insert entity with ID into Entity Framework
How to insert an entity with ID in Entity Framework 6.0? That is, insert with ID because the table does not generate it. For example: var last = _contexto.Area.AsEnumerable().LastOrDefault();…
-
2
votes3
answers2033
viewsSQL command inside a variable varchar - sql server
Good Afternoon I need to write a command inside a variable of the format varchar Set @STRING_SQL = 'update BCS_RESOURCE set DS_DESCRICAO = ''Gestão de Contratos - ''+ @DS_PERFIL + '' , [DS_pt-BR] =…
sql-serverasked 8 years, 8 months ago Junior Torres 427 -
2
votes1
answer191
viewsSaving a binary xls to SQL Server
I have an xls file that I upload and transform into binary as follows: FileStream fs = new FileStream(physicalPath + "/cadastros/documentos/" + "AWS-Estudantes_" +…
-
2
votes1
answer185
viewsCan Sql Server Management Studio handle any database?
I am asking this question because I find this DBMS simply fantastic, so I would like to use it with another database (not because I want to, but because most of the databases I have are in Mysql).…
-
2
votes1
answer1377
viewsColumn for saving SQL Server change date and time
I’m migrating a database of Firebird for Sql Server and today, in the Firebird I have some triggers on Before Insert/Update who record the TimeStamp the insertion/change and the logged in user. Is…
-
2
votes3
answers3910
viewsSelect current date
I need a select pull all records from the current date table (today), without entering the date, in sql-server and what the PHP syntax would look like as well. Since I have a column called Dtbase…
-
2
votes1
answer122
viewsHow to use a variable across the scope of batch SQL
With the batch below, I want to remove duplicate records and after that UPDATE some values. The querys are in perfect order, but adding some error checks to the execution of the process, I came…
sql-serverasked 8 years, 9 months ago Marcelo de Andrade 7,261 -
2
votes2
answers747
viewsHow to make database changes without having a clear primary key?
I need a method to change data in an SQL Server table. According to my client, all the table data can be changed. For having this possibility, I am without a fixed and unique reference frame for the…
-
2
votes2
answers6895
viewsHow to define "charset" of a table in SQL Server?
In Mysql to define the charset of a table we can use so: Mysql: create table user_details (...) default character set = utf8; How can I do the same in SQL Server?…
-
2
votes2
answers5403
viewsCut the last character of a string C#
I’m creating an export from SQL for the TXT. With this I add the ";" tab after building each column. But at the end of the last column you are adding ";" as well. How do I get this ";" from the end…
-
2
votes1
answer705
viewsHow to join the two tables in this case?
I have two tables a "students" with the enrollment and enrollment and another "faz_teste" with the grades of the students in certain tests. I used the pivot command in the table "faz_teste" to…
-
2
votes2
answers19181
viewsHow to check if a table exists in the SQL Server 2005 database and if it does not exist create it and the columns
How to check if a table exists in the SQL Server 2005 database and if it does not exist create it and the columns. The purpose of this process is to create this routine for when I need to create a…
-
2
votes2
answers2102
viewsCompare values of the same field in a table
I’m starting in SQL and appeared a problem that I’m not able to solve. I have a table in which are recorded the payments of several customers, each customer made 6 payments. I need to know how many…
sql-serverasked 8 years, 5 months ago Amoedus 23 -
2
votes1
answer236
viewsSet specific ports for each database in Sqlserver
Here at the company, we have a dedicated server hosted in a datacenter that maintains numerous databases using Sqlserver. These databases by default are working from port 1433 where it is already…
sql-serverasked 8 years, 8 months ago LeandroLuk 4,989 -
2
votes2
answers5103
viewsError to connect to sql server 2014 database with java and connection string problem
I put the jar and made the build path . I’ve been trying for a while to connect with the microsoft bank but gives this error: Exception in thread "main" java.lang.RuntimeException:…
-
2
votes1
answer48
viewsProblem with clause IN
I need to use the IN clause in a situation where the in part is a string. Example: SELECT * FROM BLABLABLA WHERE 4 IN ('6,5,4') It causes me this mistake: Conversion failed when converting the…
-
2
votes1
answer140
viewsSwap rows for columns
Hi, I have the following query: set NOCOUNT on; declare @_mes int = 2 declare @_ano int = 2016 declare @_dataini datetime = CONVERT(DATETIME, '01/' + REPLICATE('0', 2 - LEN(@_MES)) + CAST(@_MES AS…
-
2
votes2
answers142
viewsHow to bring date without Sql server 2008 record
I have an SQL query adding up values of each day, returning only the days that have values. But I would also like to present the days that had no records. Consultation: SELECT DATA, SUM(VALOR) FROM…
sql-serverasked 8 years, 5 months ago Rafael 85 -
2
votes1
answer372
viewsSelect with date over 20 years
How to make a select with date of request greater than 20 years old? Select * from Pedidos Where dataPedido > ...
sql-serverasked 8 years, 5 months ago Al Unser Albuquerque 965 -
2
votes1
answer182
viewsMicrosoft SQL Server for Mysql
I need some help. I downloaded a project in c# stock control, but the database is by Microsoft SQL Server, and would like to use Mysql for connection and data logging. Follow example of connection…
-
2
votes1
answer670
viewsHelp with connection to sql server 2008 and android database
I made, following a tutorial, the connection of Android Studio with SQL Server 2008 R2 (already existing), with which I was able to make the connection normally, only I have a problem. I can make…
-
2
votes4
answers3541
viewsHow to bring records of a LEFT JOIN even if not obeying the WHERE?
Exemplifying, I have the tabela_A: cod nome 1 stack 2 overflow 3 stackoverflow and tabela_B: cod_tabela_A ano mes valor 1 2016 1 100 1 2016 2 115 2 2016 1 90 When made a LEFT JOIN, returns me the…
-
2
votes2
answers497
viewsHow to concatenate two Data?
How to concatenate two dates of the type DateTime, one of which may have its value equal to NULL, I’m trying this way; DECLARE @DATA1 DATETIME = GETDATE(), @DATA2 DATETIME select…
-
2
votes3
answers639
viewsInstall C# application with SQL Server database
I made a simple C# application using SQL Server 2008 database. When I went to install on another computer, I came across the following error: A network-Related or instance-specific error occurred…
-
2
votes1
answer548
viewsSql Server Error: is not a recognized Function name
I have two functions in sql server that are not being recognized by the database -- Não loga conexões de usuários de sistema IF (ORIGINAL_LOGIN() IN ('sa', 'AUTORIDADE NT\SISTEMA', 'NT…
-
2
votes2
answers356
viewsException with timestamp in the database
I want to enter the time and date separately in the database, which have the fields timestamp and data, respectively. And I have the following code to add the fields:…
-
2
votes1
answer256
viewsVersion error when attaching sql server database
I’m trying to attach a database to a file. mdf generated by visual Studio, at the time I created the Identity database, however I am trying to attach this database to sql server and this giving a…
-
2
votes1
answer902
viewsWindows user on IIS
I’m trying to log in to a base SQL Server 2008, with the windows user who is accessing my site published on IIS. I’ve already set up Web.Config for windows authentication, set up the application…
-
2
votes1
answer920
viewsSUM and GROUP BY doubling values
While trying to add and group values, I found that the SUM and GROUP BY are not behaving the way I hope and could not identify the cause. Making the query below SELECT…
-
2
votes1
answer153
viewsShowing Results other than a column
I have a table CAIXA, where in the column TIPO can have two results, the 00 and the 99, where 00 is the opening of the terminal and 99 the closing. I’m trying to create a query where the result is…
-
2
votes1
answer158
viewsDoubt with Script to Generate Sql Server 2014 Database Backup
I’m doing it this way: USE CEP_2014_09; GO BACKUP DATABASE CEP_2014_09 TO DISK = 'C:\Backup_teste\CEP_2014_09.bak' WITH FORMAT, MEDIANAME = 'z_CEP_2014_09', NAME = 'Full Backup of CEP_2014_09'; GO…
sql-serverasked 8 years, 1 month ago Harry 3,805 -
2
votes2
answers422
viewsApplication server
The client has no server (Windows Server or Linux) and does not want to host the system in a data center or in the clouds for example, and you want to use the system on an intranet. Currently 3…
-
2
votes1
answer197
viewsAdodataset Delphi Edit
I have a ADODataSet with the following consultation DECLARE @ID_CONTRATO_EMPRESARIAL INTEGER = :ID_CONTRATO_EMPRESARIAL BEGIN WITH V1 AS ( select C.ID_CONTRATO, COUNT(CASE AD.FUNCIONARIO WHEN 'TRUE'…
-
2
votes3
answers219
viewsoperation with data sqlserver
Gentlemen, I am migrating my Oracle system to SQL Server, I’m having trouble making the following operation SELECT CASE WHEN (EPL.DAT_VENCIMEN - EPL.DAT_FABRICA) > 0 THEN…
-
2
votes1
answer49
viewsSqlserver on a network
I have Sqlserver 2014 installed on my laptop and it is in it that I program in visual studio, but I also have a desktop on which is only installed the visual studio because I do not have much space…
sql-serverasked 8 years ago Diogo Sousa 433 -
2
votes2
answers464
viewsDifference of hours query sql server
I have the following data: 2016-10-13 09:04:00.000 1 2016-10-13 20:33:00.000 4 2016-10-14 09:10:00.000 1 2016-10-14 21:04:00.000 4 2016-10-17 09:04:00.000 1 2016-10-17 19:50:00.000 4 How to know the…
-
2
votes1
answer2301
viewsSQL Sends NULL value to a Datetime column
I have a form in VB.NET where the user informs the delivery dates and delivery forecast of the order and other information. Since he does not yet have, for example, the delivery date because he has…
-
2
votes2
answers2202
viewsUpdate of several records together with select
I need to do UPDATE with SELECT for several records, today I am with this query: UPDATE banco.ordem SET valor = (SELECT (CEILING((litros * 3.67)*100)/100) AS valor_litros FROM banco.ordem WHERE…
-
2
votes2
answers24947
viewsHow to do for loop in SQL SERVER?
BEGIN <<LOOP_EXTERNO>> FOR V_EXTERNO IN 1..20 LOOP DBMS_OUTPUT.PUT_LINE('Contador externo: ' || V_EXTERNO); <<LOOP_INTERNO>> FOR V_INTERNO IN 1..5 LOOP…
-
2
votes1
answer231
viewsHow to calculate the distance between X and Y with Intersection points
In the image above I have mapped the separation positions within the warehouse where I work. I need to calculate how far the person you’re separating travels inside the warehouse. For example if the…
-
2
votes1
answer185
viewsInstalling Visual Studio 2015 Community with SQL Server
I installed the Visual Studio Community 2015 and wanted to connect it with SQL Server, but from what I understand I don’t need to install SQL Server, I just need to download SQL Server Data Tools.…
-
2
votes3
answers18706
viewsUse of select with SUM() function
I am developing a database for a small application. My bank has 3 tables: students, disciplines and boletim_escolar, this last one I use to insert 3 individual notes. I was able to calculate the…
-
2
votes2
answers805
viewsGroup by by two fields ordered by a third
I have the following data: |--------------------------------------------------------| |USER | ID | DEVICEID | DATE | |--------------------------------------------------------| |7 | 14450 |…
-
2
votes1
answer1366
viewsPHP7 does not work with SQL Server 2014
I have a project running in Xampp with PHP 5.6 and SQL Server 2014 Express. I’m trying to migrate the project to PHP 7.1.0 but is giving error as shown below. I copied the dll to the ext folder of…
-
2
votes0
answers1279
viewsRDS Amazon recognizes the Brazilian schedule as Manaus UTC-04:00 and not Brasilia UTC-03:00
I’m starting to use AWS services and came across a "problem" on Amazon RDS. I use Sql Server and it updates your time according to the server time, but when I select the time related to mine time…
-
2
votes3
answers2186
viewsError "... is not a recognized built-in Function name" in SQL Server
I am not able to make an Insert in the SQL Server database. Follow my code: INSERT INTO TB_Cadastro (Cod_Vac, CodIN,Produtor, Codmal, DataVac, DataCompra, NumDoc, SerieDoc, UFDoc, CodMunDoc, Lab,…
sql-serverasked 8 years, 2 months ago Herick 591 -
2
votes2
answers2233
viewsHow to make Join of 2 tables without repeating data?
I have 2 tables, a call SR7010 and another call SR3010. The primary key of the two is the field R7_MAT and R3_MAT. The query I’m trying to execute is this: SELECT R7_FILIAL, R7_MAT, R7_DESCFUN,…
-
2
votes5
answers1818
viewsGroup records per day
I have the following table ID | Início | Fim | Horas 333 | 01/01/2017 | 03/01/2017 | 5 333 | 02/01/2017 | 05/01/2017 | 1 333 | 05/01/2017 | 07/01/2017 | 3 333 | 01/01/2017 | 07/01/2017 | 6 I need a…