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
-
1
votes2
answers1012
viewsFunction with return using 'case when'
I have a Function that returns the status of a request (in the database is as int) that only has two possible values, 0 (inactive), 1 (active). I was trying to increment it with 'case when' in case…
-
1
votes1
answer53
viewsDoubt with Date Formatting in sql server 2008
In my application I am recording the dates in this format: DateTime.Now.ToString("yyyy/MM/dd"); In the database I have: 2016-01-09 00:00:00.000 Now I need to make a query where I will bring only the…
-
1
votes1
answer415
viewsDoubt with return time formatted Asp.net mvc
In the application I have a query that compares the current server time with a pre-set time - saved in a table: select CAST(HORA_FECHAMENTO AS datetime) as HORA_FECHAMENTO,…
-
1
votes2
answers1051
viewsJob created on SSIS does not work on SQL SERVER AGENT
I have a job created in SSIS (working perfectly) that does not work in SQL SERVER AGENT. The job extracts some data from an access table, via ODBC, and loads it into a sql server location table. Sql…
-
1
votes1
answer477
viewsData php Pdo format
Input: <html> <form action="../controller/progPrecontrole.php" method="POST" onsubmit="return valid();"> <input type="hidden" name="id" value="<?php echo $id; ?>"/>…
-
1
votes1
answer464
viewsProcedure to delete and then insert data
Someone could guide me on how to build a database to delete data from a table (already created with SELECT INTO), every day such an hour and then fill it again. Thank you for your attention.
-
1
votes2
answers556
viewsSql server - default
Good evening, I created a table to test the sql server default: I did a select to see if the default values were entered but you can see in the image that this did not occur. When does it enter…
-
1
votes1
answer45
viewsQuery result with SET STATISTICS
I was wondering if there’s any way I could get the results of "SET STATISTICS TIME ON". For example, the result of my query gave 1139ms. Is there any way I can get this result and manipulate it?…
-
1
votes1
answer324
viewsMake Trigger run update after Procedure has been run
I would like to know how I do in SQL Server for a Trigger check if the trial was executed and if it was executed, this Rigger will do another update. Thanks for your attention. Att, Marcilio…
-
1
votes1
answer5453
viewsCheck if date is between a period
On my table, I have two columns, DT_INICIO and DT_FIM, would be an Absence table. Let’s assume an employee is absent from DT_INICIO From (25/03/2016) until DT_FIM (27/03/2016), I need to make an…
-
1
votes1
answer468
viewsSelect Comparing Periods
I need to make one select comparing two periods of sales, totalling by product. Today I have this select that does this, but only for a period (01/09/2014 to 30/09/2014) SELECT ACC.PRODUTODESC…
-
1
votes1
answer215
viewsJob to write query data to an XML file
I need to save the result of a query in an XML through a job that will run scheduled daily in SQL Server. Procedure already brings the result in XML format with tags, in a variable. I just need to…
sql-serverasked 8 years, 6 months ago Brupikk 141 -
1
votes2
answers4528
viewsIncrement a number in an SQL query
I have the appointment that returns the results. I would like to add an incremental number to show the records from 1 to the end, as if it were a new column. select *, sum(valor) as ValorSoma,…
-
1
votes2
answers376
viewsSubconsulta in Lambda
I would like to do a sub-query today on SQL: SELECT intid as IDCliente, (SELECT TOP (1) int_EP FROM tbl_estagioprocesso WHERE (int_IDC = tbl_Admin.intid) ORDER BY int_ID DESC) AS int_EP FROM…
-
1
votes1
answer8934
viewsConversion failed when Converting the varchar value '???? ' to data type int
When performing UPDATE in a VARCHAR(4) column using an integer value in the SET clause. UPDATE TESTE SET ID = 9250 WHERE ID = 1234 Error is returned below: Conversion failed when Converting the…
sql-serverasked 8 years, 6 months ago Igor Marani Alves 13 -
1
votes1
answer48
viewshow to add a value per parameter to a select statement in sql within a simple table-Valued function?
this is my code and wanted to add a value to a select statement that is passed by parameter to a simple table Valued function. Here is my code: CREATE FUNCTION NMELHORESFORNECEDORES(@N INT ) RETURNS…
-
1
votes2
answers94
viewsAzure Shared App Service
Good morning, everyone ! I am developing an entertainment portal where you will have images and text (e.g., Earth or UOL), using ASP.NET and sql-server. I was looking into Azure and I came up with a…
-
1
votes3
answers15705
viewsSQL CASE with more than one condition
I would like to know if it is possible to use the CASE more than 1 condition. In this query I have calculations that need to be done when a.operacao == 'C' but which depend on the value of…
-
1
votes1
answer225
viewsRun an Insert in the temporary table in SQL Server
I have the following code below. declare @ac varchar(max) = '(' +…
sql-serverasked 8 years, 5 months ago Fabio Mosk Fabinho 53 -
1
votes2
answers1228
viewsReplace NULL with string
In a datetime field, when the value is NULL should only return -, tried the function IFNULL SELECT ISNULL(data, '-') as data FROM tabela but it returns me the error Microsoft OLE DB Provider for SQL…
sql-serverasked 8 years, 5 months ago Marcelo de Andrade 7,261 -
1
votes1
answer1439
viewsPDO DBLIB AND UTF-8 ENCODING
I am in a project using UBUNTU-SERVER 64bits as WEBSERVER. In the project I chose the Microsoft Sql Server 2012 database which I have a short-term license to use. With a lot of effort I got the…
-
1
votes1
answer749
viewsThe various part identifier "System.Data.Datarowview" cannot be associated
Try { if (cmbFavorecido.SelectedValue != null ) { txtID.Text = cmbFavorecido.SelectedValue.ToString(); cn = conexao.ConectarSqlServer(); cn.Open(); SqlCommand cmd = new SqlCommand("select…
-
1
votes1
answer47
viewsHow should the data of a table be selected through junctions?
When using the SELECT to obtain data from tabela_A by making a junction with the tabela_B, normally, and believing it to be the correct form, we use some of the commands JOIN. Ex: SELECT codigo,…
-
1
votes4
answers739
viewsIs it possible to put an "IF" condition on media to Internet joins and other Where conditions in SQL Server?
I have a procedure that takes a parameter that can be 0, 1 or 2. When it is 1 or 0, it needs to consider the line where it has "and bol_portfolio = @eh_port", but when it is 2, it cannot enter this…
-
1
votes1
answer6395
viewsGroup by with SQL Server error
Good morning, I would like to know why my SQL query is not working, I am using SQL Server 2008 and my GROUP BY is going wrong. I have checked and the table names are correct and are filled in…
-
1
votes1
answer92
viewsMigrations error c# MVC
I created a Finance Drive Controller, but when I click on the menu to list returns the error: Invalid Object name 'dbo. Move'. Why did that name stick? It was supposed to be Movimentacoes. PS: I…
-
1
votes1
answer966
viewsInsert via Entityframework error "IDENTITY_INSERT is set to OFF"
I have several models and for some reason one of them presents the following error: Cannot insert explicit value for identity column in table 'tbl_boleto' when IDENTITY_INSERT is set to OFF. I…
-
1
votes1
answer333
viewsSave value from a select in Session
Good morning, I have a select where I bring the categories in my php site, after selecting the category I needed to redeem the value field to use it in the select of the sub-category. I believe that…
-
1
votes1
answer679
viewsConversion of Oracle to Sqlserver
Context: Currently I work in a system that uses the database oracle, but now I’m going to need the system to use sqlserver. My goal is to convert DDL and DML for sqlserver, I see there are some…
-
1
votes1
answer13610
viewsPercentage calculation in SQL SERVER
I have a little doubt that I am not able to solve, I looked here in the community, but I did not find exactly what I want. My situation resembles the following: I have N product records in my…
-
1
votes1
answer2356
viewsIncorrect syntax error near the keyword 'FROM'
This code generates the following error: Msg 156, Level 15, State 1, Procedure totalGastoPedido, Line 7 Incorrect syntax near the keyword 'FROM'. CREATE FUNCTION dbo.totalGastoPedido(@id_mesa int)…
sql-serverasked 8 years, 4 months ago Alexandru 61 -
1
votes1
answer199
viewsUpdate table with data from another table decreasing character
Hello, I have the bank BDMCOM1 that has a table Product Balance and a column Quantity with values like: 1,000. But I have another bank BDMCOM1_V3_ALEA that also has the table Product Balance and…
-
1
votes0
answers117
viewsI cannot access database via SQL server - DSN
I have a class that I can connect to Mysql, and I would like to use it to access a database on a local network and that is in SQL SERVER 2014. private static function Conectar() { try { if…
-
1
votes2
answers11627
viewsConvert "hh:mm:ss" to int minutes
I have the following function that calculates the hours 01:00, returns 60 minutes. but the column of sql store in time(0 format) 01:00:00, What error in my function, I do not know how to increment…
-
1
votes2
answers190
viewsEntityframework Storedprocedure recover parameter output
How to recover the Output parameter of a storedProcedure? SP Example: create PROCEDURE StoreProcedure_Name @ParametterWithNummvalue varchar(50) = null, @In_Parameter varchar(50), @Out_Parameter…
c# sql-server entity-framework stored-proceduresasked 8 years, 7 months ago Alexandre Previatti 630 -
1
votes3
answers4847
viewsINSERT inside a SELECT - SQL Server
I need to do an INSERT inside a SELECT in some cases in my Query. An example of how accurate: SELECT IdTabela, Nome, CASE WHEN IdTabela > 10 THEN INSERT INTO TabelaExemplo (IdTabelaExemplo)…
-
1
votes1
answer393
viewsSave a field log only if it is Insert (Trigger SQL Server)
I have a Rigger that fires when it is Insert/update FOR UPDATE, INSERT I check if the field was changed with: if update (nome) --faça algo How do I know if I am entering a record in the table to…
-
1
votes1
answer819
viewsHow to make a basic configuration in the persistence.xml file to access a database in SQL Server 2008?
I searched about how to set up the file persistence.xml in a basic way, however, I was even more confused about this configuration. So I would like to know how I can make a basic configuration in…
-
1
votes0
answers85
viewsWhat is required to connect to an external SQLSERVER database to my application?
I have a hosting that I need to connect to a bank Sqlserver external in a php system I am creating. I insert all data correctly but always gives connection error showing the message:…
-
1
votes0
answers132
viewslike %TEXT% in full text search
I would like some help regarding the search using full text search in SQL Server. Today I have a table that stores materials and I’m doing a search using full text search with contains getting like…
-
1
votes3
answers1437
viewsFind higher sum value and show id
Talk guys, all right? I have this table Table EMPREGADO_PROJETO +--------------+-------------+-------+ | rg_empregado | num_projeto | horas | +--------------+-------------+-------+ | 20202020 | 5 |…
-
1
votes1
answer61
viewsSQL data count filtered by multiple tables
I have a PHP page where I have to generate a chart of "Registered sellers" filtered by region. The problem is that the Sellers table has City Id, the City table has State Id and the State Id has…
-
1
votes2
answers1764
viewsRecover last inserted Datasnap ID / Sqlserver
I am using Sqlserver with my Delphi XE10 Datasnap application, but when I do an insert I would like the server to return me the id that was just entered in the auto increment (Identity) field of…
-
1
votes0
answers26
viewsCreate Partition
I’m sharing a table in my database, I created Function Partition and Scheme Partition. But when I go to Create Partition Wizard the Radiobutton Existing Partition Function gets disabled even with…
-
1
votes1
answer344
viewsGroup lines with null
How can I remove the null lines and leave only the dates next to each other; Example: 48010255 | 2016-06-10 07:46:41.573 | null | 2016-06-09 12:36:22.243 SELECT cod_pista ,DT_ENTRADA =…
sql-serverasked 8 years, 2 months ago DanSan 13 -
1
votes1
answer1045
viewsInsert large amount of data into sql server
I downloaded a list of cities on the internet. There are more than 5,000 municipalities. I tried a simple Insert and could not. Exceeded the maximum number of 1000 records. Then I tried with Bulk,…
-
1
votes1
answer89
viewsHashbytes with different value when selecting and writing with update
SELECT HASHBYTES('MD5','123') This select above returns me the following result: 0x202CB962AC59075B964B07152D234B70 But when I update the table using the same hashbytes UPDATE USUARIOSLOGADOS SET…
-
1
votes0
answers973
viewsA transport-level error has occurred when Receiving Results from the server
I have an app Asp.Net MVC 4 (with Entity Framework and SQL Server) that works normally on my application server, but now I had to work with redundancy and load balance with two new servers for the…
-
1
votes1
answer1147
viewsIndex making sql query too slow
the DBMS in question is SQL Server In my system, we have a table that stores book releases. The table has a considerable amount of records, currently (around 1.2million). Has an index clustered over…
-
1
votes2
answers382
viewsFilter SQL query
I own a field called emailMSG0 within a table in the database. This field contains various information. Is there any possibility in SQL I filter what I want to get inside this field emailMSG0 ?…