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
-
0
votes0
answers96
viewsSchedule sql server 2014 job
I have a trial that I would like to run every X time. I have scheduled everything in sql agent. My question is this, I need to replicate this process in all bases to be able to use with the command:…
-
0
votes3
answers2051
viewsDifference between dates on multiple lines
Is there any way to make a DATEDIFF/LEAD/LAG in SQL Server to calculate the difference between dates taking into account the date of the previous/next record. SELECT SELECT NUM, CLIENTE, EMISSAO…
-
0
votes1
answer208
viewsDoubt with DATEDIFF days interval between dates
I have a query that I need to return the interval of days, the problem is that the date fields are defined as varchar(30). --a data teria que ficar assim SELECT…
sql-serverasked 8 years, 7 months ago Harry 3,805 -
0
votes3
answers672
viewsCondition in Where SQL Server
I have a SELECT with several LEFT JOIN, but I need to consider all of these LEFT JOIN in some conditions, already in another condition I need to disregard a JOIN done. As an example below: SELECT *…
-
0
votes1
answer476
viewsReturn a CURSOR from a Sqlserver using dynamic sql (sp_executesql)
In the oracle I can do as follows : OPEN MY_CURSOR FOR 'SELECT * FROM MY_TABLE' How to get this result in Sqlsever? I want to return a cursor by mounting a dynamic sql in the Procedure. I’m…
-
0
votes1
answer3861
viewsCatch the time of formatted sql server database
My database has a difference of 4 hours, support so far has not given a solution, so I would like to know how I can format the time out: select CAST(HORA_FECHAMENTO AS datetime) as HORA_FECHAMENTO,…
-
0
votes1
answer57
viewsC# com Storeprocedure
Good evening guys I’m making a system for college and I’m trying to do with Procedure more is not recording on the bench I think there’s something wrong but I don’t think what it is I tried to use…
-
0
votes2
answers200
viewsHow to select the foreign key id in the main table?
public List Select() { List ListaCaminhao = new List(); SqlConnection conexao = new SqlConnection(strCon); string sql = "Select * from Caminhao;"; SqlCommand cmd = new SqlCommand(sql, conexao);…
-
0
votes2
answers1523
viewsDoubt with DROP COLUMN sql server command
I tried to delete a column from a database, checked that there are restrictions. ALTER TABLE dbo.TB_ESTRACAO DROP COLUMN MULTIPLIER I get a message, how can I resolve this? I thank you! Message…
-
0
votes2
answers216
viewsPerform Insert into in c#List
One could give an example of what an sql Insert would look like in a list in c#?
-
0
votes1
answer178
viewsHow to verify integrity or violations in SQL Server database?
I created an application to run in the background to back up my SQL Server database using the class Backup of Microsoft.SqlServer.Management.Smo. I would like to add to this backup tool something…
-
0
votes1
answer224
viewsTotal SQL Records in all columns
I need to return the total query records in a column, even repeated, like this: However, the query is kind of boring. A query of 106 lines, with several SUM() and with a mandatory ORDER BY. I cannot…
-
0
votes3
answers1696
viewsHow to transpose rows into columns?
It’s already been answered by Motta, thank you for your patience. How can I transpose rows to columns in Sqlserver, so something like that: Stick to this format?…
-
0
votes1
answer4399
viewsSQL Server query SQL with COUNT and INNER JOIN
I have a page in PHP where I have to return data from two tables that are in a database SQL Server. One of the banks is registered sellers and the other is of the categories where they are…
-
0
votes3
answers204
viewsOrder by or filter in Sql Server
It’s possible to use order by or some filter in Ner Join or left Join or I’m trying to do it wrong. I need to bring in a query a column that is in a daughter table, but I need it to be the column of…
-
0
votes1
answer186
viewsError while writing data from some tables via application
I have an application in Asp.net mvc that, among other functions, registers personal data of customers. We recently switched the database access from one server to another, which has a copy of the…
-
0
votes1
answer119
viewsHow to delete record from 2 tables where one contains the left 0 SQL SERVER
I have 2 tables in which one is inserted the records that comes from a file txt and the other the records that comes from a file excel. With this, I need to delete the records from the table txt…
-
0
votes2
answers482
viewsInsert time and time into database
I want to enter the time and date separately in the database, which have the fields timestamp and data, respectively. I have the following code on the insert button: SqlCommand sqlInsertCabecalho =…
-
0
votes1
answer4700
viewsHow to create a local database in SQL server 2016?
I installed SSMS 2016 (Sql Server Management Studio) days ago on my PC but I can’t create a local database. The only thing I do is connect with a database I hosted on Azure, but when I go to create…
sql-serverasked 8 years, 6 months ago Qu33n 145 -
0
votes3
answers3965
viewsCheck the existence of Dice?
Is there any way to use a Script check if an index already exists in a table? I got the following script that generates an index in a table: CREATE NONCLUSTERED INDEX [meu_indice] ON…
-
0
votes1
answer43
viewsPrevious Record Search (Mileage)
I am trying to put together a report for supply management. I have a Supply Table with the following fields: DataAbastecimento, CódigoVeiculo, KmAbastecimento, Quantidade, Valor In the Report I’m…
-
0
votes1
answer528
viewsSelect field from next line
I need to make a query bringing the second value of a field to the first line, that is, I need the value of the first field of the column "Time1" to be filled with the value of the second field of…
-
0
votes1
answer163
viewsSQL server error
I’m doing the select below and cannot perform: SELECT DISTINCT U2.NM_ORG AS [Orgão Subordinado], U1.NM_ORG AS [Unidade Gestora], E.NM_EPG AS [Nome Funcionário(a)], C.NM_CG AS [Cargo Funcionário(a)],…
sql-serverasked 8 years, 5 months ago Dimas Victor 1 -
0
votes1
answer178
viewsSQL allocate record (Rowlock)
I am developing an application, and I am facing a problem about competition of records. What happens is that I have several people who can access the same record, so I needed that when a user clicks…
-
0
votes1
answer2246
viewsBest Database for Android Application
Guys, I have a question on which bank to choose for an android application: Sql Server or Sqlite? I have a little Crawler, which doesn’t need to run every time, just once, and when there’s some…
-
0
votes1
answer157
viewsUsing Multiple Schemas with Entity Framework 6
I am starting to work with the Entity Framework, and I need some example of how I can define for my tables the Schema’s that each one is contained. My database was created as in the example:…
-
0
votes1
answer143
viewsGenerate report in Azure
I need to generate reports in an MVC application that will be hosted in Azure and I learned through this tutorial: Using Report Viewer in ASP.NET MVC that it is necessary to hire a Virtual Machine…
-
0
votes1
answer1179
viewsQuery between different databases in SQL Server
Given this query: SELECT PontoSecullum4.DBO.funcionarios.N_FOLHA, PontoSecullum4.DBO.funcionarios.NOME, PontoSecullum4.DBO.funcionarios.EMPRESA_ID, 1 [ORIGEM] FROM PontoSecullum4.DBO.funcionarios…
-
0
votes0
answers127
viewsUnable to locate Control ID in Controlparameter - Asp.Net
Hello, I’m having a question getting the id of a book author and adding it to a book creation, and the book to be published should have an auto-incrementing Book ID, a book name and the author ID.…
-
0
votes1
answer287
viewsJPA Eclipselink - Trigger SQL SERVER
I’m having a problem with a Trigger created in SQL SERVER. When I insert the data into the table that starts Trigger directly in SQL SERVER Trigger works normal, however when performed insertion by…
-
0
votes1
answer937
viewsRunning SQL Server External HD Database
I am starting the construction of a web application using SQL Server and talked to my client to provide the backup of the database avoiding access to its production base, because it has no…
-
0
votes1
answer63
viewsINSTEAD OF (Deleted table)
I’m having trouble creating this Rigger: CREATE TRIGGER TGmonitoraClientes ON TB_CLIENTES INSTEAD OF DELETE AS BEGIN UPDATE TB_CLIENTES SET clienteAtivo = 0 FROM TB_CLIENTES WHERE CODcliente =…
-
0
votes1
answer370
viewsConcatenate SQL Server records
I have a problem with a query, where I need to concatenate records from a table. I need the select take the FormID and concatenate the records of AcaoID only if Permitir for 1. Query: Declare…
-
0
votes0
answers62
viewsSQL Server - Create View on a server with tables from another server
Hello. We had an SQL Server with three banks, one of the application I develop, another two of two different systems, the Company’s ERP system and the Online Ordering system. This system of Online…
-
0
votes2
answers945
viewsCompare values with different conditionals in the same table
When making a SELECT COUNT(*) in the view vwNotaFiscal I get the total of lines: 3498 SELECT COUNT(*) FROM dbo.vwNotaFiscal WHERE tbEmbarques_emissao BETWEEN CONVERT(DATE,'01/05/2016',103) AND…
-
0
votes1
answer49
viewsQuery returning unwanted result
In my sql statement: SELECT DISTINCT C.TABLE_NAME,C.CONSTRAINT_NAME,C.COLUMN_NAME FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE C INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS T ON T.TABLE_NAME…
-
0
votes2
answers1259
viewsError making query with between in datetime field
I’m trying to make a between but I don’t know how to proceed. where cliente.id = (select usuario.idCliente from usuario where usuario.login = 'julio') and (cast(os.dataHora as date) between…
sql-serverasked 7 years, 11 months ago fabricio_wm 1,090 -
0
votes0
answers106
viewsEntity Framework error mapping classes from existing database
I have an SQL Server database and had the mapping classes automatically generated from the existing database. However, when I run the application, it gives the following error: (404,10) : error…
-
0
votes0
answers146
viewsIs it possible to record audio in the Sqlserver database working with the Vb.net language?
I have an application made in VB.NET where I have customer registrations. Now I need to implement as if it were a certain permission from customers to third parties who can represent such customers.…
-
0
votes1
answer79
viewsProblems with Asp, value recovery returned from a stored Procedure
Good afternoon, I’m having trouble recovering a returned value in a stored Trial. The database is sql server. Procedure executes an Insert and returns the id of this data, however I cannot recover…
-
0
votes1
answer191
viewsTRIGGER and ASSERTION sql server
I would like to know how TRIGGERS and ASSERTIONS work I am beginner and I have no idea where to start?
sql-serverasked 7 years, 10 months ago Moisés Ramos 33 -
0
votes1
answer84
viewsI can’t register dates
I have a form with two dates, however, when I register them returns me the following error: Character string not recognized as valid datetime. What can it be? This application is done in four…
-
0
votes0
answers26
viewssql stored Update Value With value from the previous record in the same table
I have a table with several repeated names sequenced by another column called id2 where each 1 of these records has a column with a quantity Example : Name-Quantity-Value2-id2 teste1-1000-0-1…
sql-server function select-sql sql-update stored-proceduresasked 7 years, 9 months ago Bruno Almeida 39 -
0
votes1
answer549
viewsQuery with date and time in sql server
I have a field in the "char" type bank, I am returning the dates this way: select CONVERT(VARCHAR(20),HORA_FECHAMENTO) as HORA_FECHAMENTO, CONVERT(VARCHAR(20), DATEADD(hour, +0, getdate()), 120) as…
-
0
votes0
answers31
viewsSql driver not found
I am with PHP version 5.6.25 successfully installed the mssql extension and it appears in the PHP extension list marked that is running the following extension PHP_PDO_SQLSRV_56_TS but when I give a…
-
0
votes2
answers3045
viewsFormat PT BR date and time return in PHP
I’m using the function strtotime of PHP to format the date that come in the database SQL SERVER and is working normally on the local server, but on the web returns the date 12-31-1969 21:00 PM.…
-
0
votes0
answers128
viewsError in sqlsrv_query and sqlsrv_num_rows() functions
Good afternoon, I don’t have much experience in php I’m starting now with this language and I’m having a problem with two functions follows print of the problem: Warning: sqlsrv_query() expects…
-
0
votes2
answers1804
viewsPhp connected with SQL Server
How can I connect php to sqlserver (Pdo)? It seems simple, but I’m not getting... I’ve enabled the driver all ok Attached is the name of the server, I will run in place ...…
-
0
votes1
answer471
viewsTransfer data from SQL Server to Sqlite with Android
I have a software that is connected to an SQL Server database, but now I am making the software on Android using Sqlite. I need to transfer the SQL Server database (with the data) to my Sqlite.…
-
0
votes2
answers379
viewsBirthday listing in a date range
You are giving me an error when I do this query to compare the day and month of anniversary in sql format(data,'MM-dd') . need to take from date the month and year and make a between Select…
sql-serverasked 7 years, 8 months ago usersantos 23