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
votes1
answer116
viewsCreate select to return last time something was non-zero
I have a table called Estoque, where have the columns NOME_PRODUTO, DATA, ,among others. The idea is that when I make one SELECT Using the date as parameter I return all products I had in stock that…
-
1
votes1
answer79
viewsIs it possible to change a user-defined table type?
I created a kind of table to use in some procedures, and after creating the procedures, I realized that I need to change some of the column types. Is there any instruction to change a table type?…
-
1
votes2
answers444
viewsJoin returning many records
Hi, I’ve researched here about this error and I haven’t seen one that fits my problem, so my problem is that I have two tables, I need to get some information from table B and insert in the query…
-
1
votes1
answer691
viewsHow to verify, amid a select, the existence of relationship of a record of an A table with records of other tables
I already know I’m a beginner and maybe I’m asking something simple, but come on. I have two tables, PROMOTIONAL and PRODUCTS, and a PRODUCT can relate to zero or many PROMOTIONAL records. What I…
-
1
votes0
answers443
viewsSQL Server Error When Converting Varchar to Integer Type
FOLLOWS THE ERROR Msg 245, Level 16, State 1, Line 2 Conversion failed when converting the varchar value '280-64460-2' to data type int. SQL DONE USE TOXICOLOGICO SELECT NomeUnidadeColeta,…
-
1
votes1
answer81
viewsHow do I get multiple columns of a table to reference a foreign key from another table?
How do I get multiple columns of a table to reference a foreign key from another table? I want all columns called "SLOT", CAN store a key from the mods table. NOTE: I’m using the latest version of…
-
1
votes2
answers168
viewsHow can I see last deleted database database database database
Is it possible to refer to the last deleted file in the database? If yes, how can I do that? The goal is to recreate it.
-
1
votes1
answer1305
viewsMSSQL How to find out which table a record has been included or modified
There is a way to find out via query which table in a database has changed from Update or Insert?
-
1
votes1
answer156
viewsHow to troubleshoot "3183" error importing a bank into SQLSERVER 2012
Good afternoon! First of all, I warn you, I’m a layperson. I need to run a local bank on my machine to work on a project. I installed the programs: SQLSERVER Express 2012 SQL Management Studio 2012…
-
1
votes0
answers167
viewsError doing Linked Server with Firebird Database
I installed Firebird 2.5 and the due ODBC driver on my computer. I tested the connection and it went all right, I called the bank DB. But when I create Linked server in SQL Management Studio 2008,…
-
1
votes1
answer913
viewsINSERT in two tables based on SELECT
Imagine the following scenario: At a certain point it is necessary to duplicate people and their respective items. If I have the following data: Table Person +----+------------+ | Id | Nome |…
-
1
votes1
answer9606
viewsString or binary data would be truncated
This error occurs when I try to run my trial, I don’t know why it happens. my code: Dim con As SqlConnection = New SqlConnection() Dim cmd As SqlCommand = New SqlCommand() Try con.ConnectionString =…
-
1
votes2
answers792
viewsSELECT by word in sql server without using Full Text Index
I need to make a query in a table with the following words: "Today the day got rainy" I need to search for any of these words. For example if you found the word "day", would have to return the…
-
1
votes1
answer1224
viewsInstall Full-text in SQL Server
I plan to use full text index (Full-Text) in my SQL Management Server 2014. I created a catalog with the command: CREATE FULLTEXT CATALOG [noticiasFullText] WITH ACCENT_SENSITIVITY = OFF And when I…
-
1
votes2
answers1006
viewsISNULL in a Case When
I’m making a select using the CASE WHEN in Sql Server, so that the existence of a record is checked, if it exists, it selects in a table, otherwise it selects in another table, but the two can…
-
1
votes0
answers292
viewsSQLSERVER windows authentication
I’m trying to connect to SQLSERVER 2012 with windows authentication and it shows me this error, I have two servers created, tested both but it didn’t work before when I used it connected. `TITLE:…
sql-serverasked 7 years, 8 months ago Romulo Sousa 569 -
1
votes0
answers76
viewsHow to use more than one Dataset in a single table in Reporting Services
Good afternoon, I would like a great help, I am trying to use two Datasets within a single table in Reporting Services. Could someone please let me know if there’s any way to take such action?…
-
1
votes1
answer994
viewsPDO sqlsrv is in phpinfo but does not work
I’m trying to access an SQL Server server from another Ubuntu server 16.04 using PHP, I did the entire installation process of the drive informed by Microsoft’s own website and phpinfo is shown the…
-
1
votes1
answer1197
viewsDelete Duplicate Records by Group BY
Good morning, Does anyone know if there is a possibility to delete duplicate records as follows: I have a query that brings the result All fields repeat themselves except the NDO field, and…
-
1
votes1
answer257
viewsWrite address by coordinates and pick up google maps
I know google provides its api for maps. I would like to record addresses but also the coordinates, that when the user read these coordinates, already showed on his screen or in his App, the map of…
-
1
votes1
answer393
viewsHow to import log file into Asp.net mvc with Entity framework
I would like to ask a question and I do not know how to structure my need.. I need to import/export a file with records, and depending on each record will be a different table, with its references…
-
1
votes2
answers99
viewsReturn values less than 10 from a column with Datediff
I need to return values less than 10 in a column with DATEDIFF and others between 10 and 20 of the same column. Someone can help me? SELECT CONVERT(VARCHAR(10), (MAX(REMESSA.DT_USO_FIM)),105) AS…
-
1
votes1
answer76
viewsError using Sqlcommand and foreach
I’m trying to go through a list of objects and persist your data in Sqlserver: foreach (var item in pedidos) { cmd.CommandText = "INSERT INTO MinhaTabela (Coluna_A, Coluna_B, Coluna_C) " + "VALUES…
-
1
votes1
answer60
viewsError Calling Up Report
I have an error below, when I call a report, which has a query in the database, I am not able to solve. Give a look at the result has nothing to zero Follows the code: SELECT SD.D2_DOC,…
-
1
votes1
answer68
viewsCHECKDB found 0 allocation errors and 0 Consistency errors in database sql server found 0 allocation errors and 0 Consistency errors in database
A few days ago, I had a consistency error problem with a database. It has a very strange behavior after the correction of it, when I execute CHECKDB found 0 allocation errors and 0 consistency…
sql-serverasked 7 years, 7 months ago user73571 11 -
1
votes1
answer667
viewsAssign a cursor value to a table column
I have a cursor. I need an Insert to insert the value of each cursor position into a table. How do I do this? I need to enter the cursor value exame_cur. My code below: set nocount on declare…
-
1
votes1
answer648
viewsImport MS Access data to Sql Server via code
I need to import data that is in an Access database via Sql Server code. My software that is made in C# for many years has been integrated into an Access database. From now on we are migrating to…
-
1
votes1
answer751
viewsDivision error by zero - Query SQL
I have the following query below, however, when I run it, the following message occurs: erro de divisão por zero. I tried to use the function nullif, but without success. How to solve? SELECT…
-
1
votes1
answer530
viewsStandard structure of a SQL Server database
I have a model structure, I wonder if it is suitable to a good standard. USE [teste] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author:…
-
1
votes1
answer107
viewsError in SQL Pivot function
First question: The Column that will become Row (in this case I specify the header) can be repeated ? I have several records that repeat, Example to Column Description: I’m trying to do it like…
sql-serverasked 7 years, 6 months ago hard123 2,329 -
1
votes0
answers282
views'SET ANSI_WARNINGS ON' Orange 5.4
I am using Laravel 5.4 with 2 connections, one of them is just to access some Views of a Sql Server database, and one of them makes a LINKED SERVER which forces me to set some settings before making…
-
1
votes1
answer61
viewsDoubt - SQL Server 2012 Query
People, in the query below want to put a condition within the Where that bring only the tasks that are due two months after the opening date. For example. The task 11111 was opened on 01-11-2017 and…
-
1
votes1
answer340
viewsTo return multiple rows with sql Server byte array
I need to perform a query, in a table, where the data is of the type varbinary(max), then created the method below: public List<byte[]> preenche_fotos(string nCrm) { consql.bd_string();…
-
1
votes2
answers1605
viewsHow to configure the Connection String in App.config?
I would like to mount using saved String: InstanciaSQLServer, UserSQL and PWSQL, it is possible that? Example of my app.config <configSections> <sectionGroup name="userSettings"…
-
1
votes2
answers1338
viewsT SQL Merge Two Lines in One
I have a common id (103307) and would like to join two lines in one. From image 1 and leave as image 2. It is possible?…
-
1
votes1
answer301
viewsDocument search screen with paging and search filter with Asp.net
I have the layout of a search screen, it has to show documents from my sqlserver database. To facilitate the search I put filter and as they are very documents it would be interesting to make…
-
1
votes2
answers3778
viewsReturn the shortest date within Select
I have the following table: CREATE TABLE [dbo].[Crm_man]( [id] [int] IDENTITY(1,1) NOT NULL, [nCRM] [int] NULL, [cliente_CRM] [int] NULL, [item_CRM] [int] NULL, [qnt_CRM] [int] NULL, [descri_CRM]…
-
1
votes2
answers162
viewsPrevious dates
I am making report in which I need to always get the date of customer registration in a previous month. Example: I am in the month of December 2017, I want to pick up customers who were registered…
-
1
votes2
answers67
viewsConvert Data Sqlserver
I would like to convert02/01/2018 for 2018-01-02 00:00:00.000, what I found on the internet so far was: select CONVERT (datetime, '02/01/2018', 120) Who returns to me2018-02-01 00:00:00.000, a…
-
1
votes2
answers4225
viewsConvert Varchar to Time in SQL with data longer than 24 hours
I am developing an SQL query and in case I need to convert a field of hours that is in varchar for time to then make a media of this field (I will use Datediff together). The problem is that CONVERT…
-
1
votes1
answer241
viewsGroup data from a Query?
I do a GROUP BY in a query result and the result comes this way: I wonder if it is possible to bring together in this way? I wonder if this grouping is best done in PHP or Query and how it can be…
-
1
votes2
answers1441
viewsFind regular expression record in mssql
I have a column that stores data in the following pattern #campo#=valor;#campo#=valor (and so on) ex: '#aaaa#=1111;#bbbbb#=2222;#cccc#=33333' However, they added ; within the value and I wanted to…
-
1
votes1
answer325
viewsEntity Framework 6 - Migrations - Add c column/ default value and name Constraint
I want to add a column like BIT to an existing table with a default value 1 via Migrations. The challenge is...we have in the company a standard for the name of constraints and it is not legal the…
-
1
votes0
answers37
viewsSql Pagination in the past
I’m trying to implement the sql pagination in my Procedure, I have already taken several examples but I did not get the desired result. I have a trial that makes Lead queries at my base. I would…
-
1
votes1
answer1067
viewsDifference between hours and minutes days in Sql Server?
I got two columns like datetime. I have tried in many ways to catch the difference between them, but the number of days is always incorrect. Example: Data1: 2018-01-17 17:00:00 Data2: 2018-01-18…
-
1
votes0
answers96
viewsProblem with changing Trigger
I have a table that receives data all the time, almost every second. This table has a Trigger that after inserting a new row inserts this record in another table. I need to include a new Rigger in…
-
1
votes2
answers404
viewsGet data from all days of the months in the query range
I have a query in SQL Server that returns me the data from 1 ago SELECT titulo, categoria FROM posts WHERE dataCadastro BETWEEN DATEADD(year,-1,GETDATE()) AND GETDATE() ORDER BY dataCadastro DESC";…
sql-serverasked 6 years, 10 months ago DiChrist 4,567 -
1
votes1
answer237
viewsFK error while running Migrations on C#
I have the following scenario public class branch() { public Branch() { Branchs = new HashSet<Branch>(); } [StringLength(80)] public string Description { get; set; } [Required]…
-
1
votes2
answers42
viewsHow to Update in 3 lines in a query
How can I update to change the value of 3 lines? I have a similar structure: Id | Nome | Ordinal 13 | Juizado Especial Cível | ª 14 | Juizado Especial Criminal | ª 15 | Juizado Especial Cível e…
sql-serverasked 6 years, 9 months ago Vinix Gonzalez 81 -
1
votes1
answer1462
viewsGroup duplicate Sql Server lines
I created the query where I have a table Products and another stock (1:N) need to add the stock of each product has in the stock table, I made the following query: select DISTINCT…