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
answers183
viewsConnection to slow database
I have a program in C# that when I start and ask to show me the data entered in Sql Server takes time to open, but after this time is already faster. There’s a way for the first time to be faster?…
-
0
votes1
answer41
viewsLimiting functions according to access level
I have the form MenuPrincipal and the FormLogon, where the latter, after carrying out the login validation queries, calls the Menu and closes. I need to limit some buttons and controls according to…
-
0
votes1
answer129
viewsxp_cmdshell how to place folders that have space?
I put a folder in the terminal exec xp_cmdshell 'dir b:\teste\*xlsx*' exec xp_cmdshell 'dir b:\teste teste\*xlsx*' When I add the space it does not find. It is impossible to change the name of all…
-
0
votes2
answers368
viewsC# and Sql Server, inserting with proc using BEGIN TRAN
Good night! I am entering a record using the C# and Windows Forms, I am using a proc that inserts in two tables at once, the code is working, but, I created a rule that the store can only have only…
-
0
votes1
answer464
viewsBegin Transaction and Save Transaction SQL Server
I have a Storedprocedure on a system I’m working on and I have the following code begin transaction; save transaction Integration_SP; -- CODIGO commit transaction; I have been searching and only…
-
0
votes1
answer38
viewsDoubt Case Sqlserver
I’m using the following case: CASE WHEN RESPOSTA.CD_RESPOSTA = 1 THEN 'ATENDE' WHEN RESPOSTA.CD_RESPOSTA = 2 THEN 'NÃO ATENDE' ELSE 'NÃO APLICÁVEL' END AS DS_RESPOSTA I have the value of…
-
0
votes0
answers16
viewsJavafxml application with datepicker, insert value in BD
I have to enter the value of a datepicker that comes in DD-MM-YYYY format in the database and when I run the application I get this error: "com.microsoft.sqlserver.jdbc.Sqlserverexception: Operand…
-
0
votes2
answers2827
viewsSQL Server Create a filter in a Datetime field, bringing the previous 24 hours (not counting the current time)
Good evening, I’m having trouble putting in a date filter, I have a query where I bring the information of CD, Crane and Dtregistro (datetime) In this query I am already filtering the 24 hours…
-
0
votes1
answer80
viewsSelect data from last database file and select file data from time before last. Compare Data
After fetching two uploaded files, I go to the table to compare the data within them Amid 8: 50 e 23: 50 (with an interval of one every hour) it performs a check in a file of that bank that I call…
-
0
votes1
answer201
viewsSlow Query - SQL Server 2012
The query below is taking on average 30 seconds to execute. I know that very likely can be the various or and like, but I am searching from the log table and not always the id will be the same, why…
-
0
votes1
answer435
viewshow to subtract column date with system date?
I have a date column data_novo and I want to know how many days the product is open, I have to make a subtraction account between the "system date" and the date that is in the column data_novo. And…
-
0
votes1
answer114
viewsorder by specific text
How do I make a order by by text criterion? I have a column with some ratings and wanted it to come in the order I determine. Example: 'carro1' 'carro3' 'carro5' 'carro10' 'carro2'…
-
0
votes1
answer626
viewsHow to update a field from a Database table using a Stored Procedure?
I basically have a database table, which has a field called DESCRIÇÃO and the table is called Tabela123 I have 10 records in this table, and in the DESCRIPTION field I have the sentences: Hello, you…
-
0
votes1
answer146
viewsDoubt in an SQL query
Through this DER template I would like to make an sql query that returns the following information: Write a command that shows how many customers are single.…
-
0
votes1
answer48
viewsSQL in php script
SELECT CAST(REPLACE(CAST(DsXML as Nvarchar(Max)),' xmlns="http://www.portalfiscal.inf.br/nfe"','') as xml).value('(/nfeProc/NFe/infNFe/transp/vol/qVol/node())[1]', 'int') as [qVol] FROM SPDNFE WHERE…
-
0
votes1
answer183
viewsQuery SQL error in PHP
I came across an sql error, but when running the query in SQL Server Studio returns me the normal query. Query that is below. SELECT CAST(REPLACE(CAST(DsXML as Nvarchar(Max)),'…
-
0
votes0
answers142
viewsControl X-axis markings in date data charts
I have records in the database and a graph where I can visualize them. The graph is of data x voltage in volts. When I have few records in the table the chart shows exactly the date recorded in the…
-
0
votes3
answers69
viewsI have this cursor and the Where 'between' gives error. I wanted to select the years 2005 to 2008
DECLARE @Year int DECLARE db_cursor CURSOR FOR Select distinct Year(OrderDate) as Year From Sales.SalesOrderHeader Order by Year(OrderDate) OPEN db_cursor FETCH NEXT FROM…
-
0
votes1
answer51
viewsError creating Diagrams in Sqlserver Studio 2014
This week I had a problem creating diagrams in my database ( SQL Server 2014), it returned me an error message: Database Diagram support Objects cannot be installed because this database does not…
-
0
votes3
answers282
viewsHow can I do "Inner Join"
Preiso inner join with 2 database tables, let’s say one is called equipment and another indicator type.
-
0
votes1
answer443
viewsAndroid Studio, CRUD in SQL Server 2008
I’m doing an application at the company where I can register for homeowners and visitors. I am making a connection to the SQL Server 2008 database quietly, but I cannot do CRUD in the application. I…
-
0
votes1
answer835
viewsHow to show only a result of a specific column [MSSQL]
I have the following QUERY: select id_cc_ponto_saldo_vecto, id_planta_re, tbl_cc_ponto_saldo_vecto.re, ponto_saldo_atual, convert(varchar(10),vecto_ponto,121) from tbl_cc_ponto_saldo_vecto INNER…
sql-serverasked 7 years, 3 months ago user2287892 57 -
0
votes0
answers37
viewsRemove Fixed lenght from SQL Server
The string fields of the tables in my database are coming with Fixed length as true. So if the size is 60, and I save a string with a size of 30, it fills the string with spaces up to the full size.…
-
0
votes1
answer419
viewsPYMSSQL - error
People I am facing a problem with pymssql library, whenever I try to make a connection it presents the error below: This is the connection str: import pyodbc con = pyodbc.connect("DRIVER={SQL…
-
0
votes1
answer36
viewsSQL Database Log in Restoring Pending
I have an SQL database that was accessed by someone else and it entered "Restoring Pending" as soon as they accessed. Is there any way to extract some log or any other more detailed way to know how,…
-
0
votes1
answer186
viewsHow do I save an image to the database through an application?
I have an application in c# and I want to make it possible to save a photo in the SQL database. 1- How do I mount the database structure to receive an image? 2- How to send the application photo to…
-
0
votes1
answer858
viewsConvert to decimal without adding zeros - SQL Server
I am converting a number from varchar to decimal. This number already has the boxes after the comma, and when I convert it adds 2 more zeros. Example: 12.345,67 ---> 1234567,00 The code I’m using…
-
0
votes0
answers180
viewsPHP PDO Drivers for SQL Server
It was with the same problem, I performed the steps indicated, however, I did not succeed in installing the SQL Server connection. Versions: PHP = 5.6.21; OS = Windows Server 2008 R2 Enterprise SP1.…
-
0
votes1
answer675
viewsDivision of tables with Count and Sum
I am preparing a query where I have some sums and counts and, in some parts, I need to make a division in a table that I have added or made the count, for example: COUNT(M.ID_MAILING), SUM(CASE WHEN…
-
0
votes1
answer505
viewsSQL Server - Trigger does not run after a given field
I’ve got Trigger down: CREATE TRIGGER AtualizaDataAlteracaoSegmentos ON dbo.Segmentos AFTER INSERT,UPDATE AS BEGIN Begin tran update Segmentos set DataAlteracao = GETDATE() where Id = (select ID…
-
0
votes0
answers266
viewsConflict between tables in sql servre 2012
I have a problem making a relationship between two tables in sql server 2012. How can I resolve this? Table 'tbl_chkrecebimento' saves successfully Table 'tbl_chkitens' - Cannot create relation…
sql-serverasked 6 years, 4 months ago Junior Guerreiro 617 -
0
votes1
answer647
viewsHow to add SQL Server primary key?
Good morning! maybe it is simple my doubt, but... I would like to know how to add primary key in a table not being at the time of creation (CREATE), I know that when accessing the table in "Object…
-
0
votes4
answers183
viewsPdostatement::rowCount returns -1
I need to know how many records were entered in the query below. public function CadastraCliente() { $this->conn->beginTransaction(); try { $stmt = $this->conn->prepare(" INSERT INTO…
-
0
votes3
answers2525
viewsHow can I insert multiple lines once only using Sql?
I exported a Sqlite data record to Sql Server with Dump. I need to take these records and insert them into a new table that I created to receive these records within my database in Sql server. The…
sql-serverasked 7 years, 3 months ago Gladiador 345 -
0
votes2
answers1286
viewsSort date by month
In the development of a query, I’m having a problem sorting the months. For example, in the chart appear to me first April, then January, June, August... And what I wanted to get, was the order of…
-
0
votes2
answers608
viewsError Object Reference not set to an instance of an Object in c#
I’m in trouble, when I register my route it appears an error at the time the system will make the comparison to see if the Numcarroid that is in Dropdownlist is the same that is in the bank to can…
-
0
votes1
answer43
viewsHow to compare more than one column in an IN clause?
There is a way to compare >= 2 columns in a clause IN kind of like comparing objects? For example(Will give error so the question) SELECT * FROM Usuarios1 WHERE Nome,Sobrenome IN(SELECT…
sql-serverasked 6 years, 3 months ago Leonardo Bonetti 5,313 -
0
votes1
answer49
viewsWhat is the best way to save multiple image links in a database?
List<String> _lista = new List<String>(); [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create(Veiculo veiculo, HttpPostedFileBase[] file) { for (int i = 0; i <…
-
0
votes0
answers569
viewsDatabase in "Restoring" mode
Good afternoon to you all! In SQL Server 2008, I needed to do a database conversion for one of our clients and I was going to do the backup in case there was a problem, only I mistakenly pressed to…
-
0
votes1
answer860
viewsJoin between tables that do not relate directly
I have three tables: Candidate who has an ID as pk (which has been invented) Registration that has FK for Candidate ENEM that has no id representing the candidate, only his registration and…
-
0
votes1
answer1178
viewsWorking day function
The query below in datediff is bringing the difference of days correctly, but I just want to bring the amount of working days. I already have a business day function that excludes Saturdays, Sundays…
-
0
votes1
answer95
viewsReturn of a Stored Procedure
I have an X-Action on my app that when performing it, a stored Procedure in the bank that generates a insert in a table. So far quiet. What I need is a way that when this stored Procedure is…
-
0
votes0
answers119
viewsI don’t know how to insert nxn tables
CREATE TABLE pacotes ( id INT IDENTITY(1,1) PRIMARY KEY NOT NULL, nome VARCHAR(100), valor FLOAT, percentual_max_desconto TINYINT, ); CREATE TABLE pontos_turisticos ( id INT IDENTITY(1,1) PRIMARY…
sql-serverasked 6 years, 2 months ago Junior Zeh 31 -
0
votes2
answers453
viewsTrigger with null value
Good evening guys, I need you to check if the address and phone columns are null, if you are returning an error message, otherwise effective operation. my code is like this: CREATE TRIGGER VERIFICA…
-
0
votes1
answer35
viewsConcatenate query [MSSQL]
I have a question on how I could concatenate the email column, as query below: select * from orcam INNER JOIN ccusto as a ON orcam.Ccusto = a.Ccusto INNER JOIN grupo_email b on a.Ccusto COLLATE…
sql-serverasked 7 years, 2 months ago user2287892 57 -
0
votes1
answer304
viewsDoubt - SQL Server Dates
In the script below when one task is completed the other will open on the first working day of the following month. Example: Task 10 was completed on the day 18-11-2016, then another will be…
-
0
votes2
answers60
viewsData search without formatting sqlserver with select
I have a field on the table Clientes by name CPFCNPJ but your data is formatted with dots and hyphens and would like to make a SELECT formatting this data without punctuation. It is possible to…
-
0
votes0
answers51
viewsColumns of sql server tables are not recognized in php
I have columns that were saved in sql server with uppercase letter, when I receive in php I needed him to recognize them both minuscules and uppercase. For example: select * from rzv_aluno records:…
-
0
votes0
answers81
viewsChange Mysql query to work on SQL Server and Oracle
Would anyone know how this query in Mysql would look in SQL Server and Oracle? SELECT COUNT(*) AS TOTAL, SUM(EVENTO = 7 AND RESULTADO = 0) AS QTD_RX_OK, SUM(EVENTO = 7 AND RESULTADO <> 0) AS…
-
0
votes1
answer325
viewsInsert date written to the textbox in a certain format for the database
Code: private void button1_Click(object sender, EventArgs e) { conn.Open(); using (SqlCommand cmd = new SqlCommand("INSERT INTO (StartDate) VALUES(@StartDate)", conn)) {…