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
-
3
votes2
answers1567
viewsMuch interface query for many SQL server
Hello, I have a question to make a select in the SQL SERVER. I have 3 tables. They are, BOOKS, AUTHOR and LIVRO_AUTOR. To LIVRO_AUTOR has foreign key to the id of BOOKS And AUTHOR. I need to make a…
-
3
votes1
answer1299
viewsDate is not "blank" sql-srv
I have a column in the type database date. When I change some date in a form php and leave blank the same instead of being blank she brings me this date of 1900-01-01. Below the input I use to…
-
3
votes2
answers957
viewsHow to compare set of numbers with other set?
How to mount query to compare if a set A of numbers is equal to another, of B, with the same numbers of set A, and so on. Example: Table data id conjunto numero ordem 1 1 1 1 2 1 12 2 3 1 4 3 4 1 6…
-
3
votes1
answer92
viewsHow to add the BUILTIN Administrators group in SQL Server for Operating Systems that are not in English?
During the installation of my application on a server, the following line is executed: using (var com = con.CreateCommand()) { com.CommandText = "CREATE LOGIN [BUILTIN\\Administrators] FROM…
-
3
votes1
answer199
viewsHow to launch custom T-SQL exception?
I have a Tigger for CPF validation, and I want to make an exception if the reported CPF is invalid. About the release of exceptions I’ve been reading this publishing, but in the author’s examples he…
-
3
votes2
answers87
viewsDatabase objects as Stored Procedure parameters
Why when we pass database objects as parameters in a stored database they are not accepted? Ex: @COLUNA nvarchar(30), @VARIAVEL nvarchar(50) SELECT * FROM TBL_TESTE WHERE @COLUNA = @VARIAVEL The…
-
3
votes3
answers944
viewsReturn the Id of table 1 and insert in table 2 in the same code
Talk guys, next, to with 2 tables (Group1 and Group2), there I have a form that has several fields that will be inserted at the same time in these 2 tables. But I need to insert in the table Group2…
-
3
votes1
answer228
viewsProblem with SQL Server connection
I have a PHP system hosted on a Linux server that queries a SQL Server database through the mssql. It works perfectly on the server. I needed to make some changes to this system, so I put it on my…
-
3
votes1
answer224
viewsHow to show result between 3 tables?
I have these three tables; table_1 |---------------------| | ID1 | name | |---------------------| | 1 | 'xxxxx' | | 2 | 'xxxxxx' | | 3 | 'xxxxxxxx' | | 4 | 'xxxxxx' | | 5 | 'xxxxxx' |…
-
3
votes1
answer408
viewsSqlconnection failure in C#
SqlConnection ABC = new SqlConnection( "Data Source=(local);Initial Catalog=Database1;Integrated Security=SSPI"); SqlCommand command = new SqlCommand(); SqlDataReader dataRead; I’m using this code…
-
3
votes2
answers2509
viewsHow to group multiple records into a single row
I have a query where I need the values of other related tables to be grouped in a single column. For this I use a for, however, the lines come duplicated. I would need the result to bring only the…
-
3
votes2
answers17826
viewsHow to select in date format?
How do I select using dates on SQL server 2008? When I do a search with this select: select * from NOME_TABELA where DATA_FISCAL between '2016-05-01' and '2016-05-11' The result is 12 records…
-
3
votes2
answers1269
viewsSave without accents and uppercase SQL Server
I’m creating a database, where I need to save all fields in uppercase. Searching the internet, I found the following collate that would work, but it still keeps saving with accents and in upper and…
-
3
votes2
answers223
viewsWhich database is ideal for my scenario?
I am developing a commercial automation system (C# and Windows Forms) that can be installed on one or several machines on the same local network. I did the part mobile system, where it is possible…
-
3
votes2
answers940
viewsFile import and read
I have an Asp.Net MVC project with Entity Framework 4 and SQL Server, where there is a Action who receives via POST an archive csv. Taking into account the use of memory, processing time and…
-
3
votes0
answers190
viewsHow to merge Cellula in Reporting Services
Olá Pessoal, I need a help with a situation in Reporting Services. I need to merge cells into data in Reporting Services as shown in the image below, i.e. image 1 is my current scenario and image 2…
-
3
votes1
answer2399
viewsDynamic Sql Server Query
Gentlemen, I have the following problem: I have to set up a consultation that works with various views, for example, one of products or one of people. I’m doing some tests with this code: declare…
-
3
votes3
answers717
viewsSQL - Return zeroed records
Good morning, I have a query that is only returning the months with sales consumption, which should be correct. Only now a blessed user wants me to return every month, including those who have no…
-
3
votes2
answers313
viewsDiscovering the binary value in SQL Server
Is there a function in SQL Server that converts an integer into binary ? Example: SELECT Funcao_Binario(2) -> Saida : 0010 SELECT Funcao_Binario(4) -> Saída : 0100 SELECT Funcao_Binario(5)…
-
3
votes1
answer2845
viewsSQL Server - How to guarantee permission from SELECT to View without giving permission in the base tables?
I need help with a problem involving permissioning of objects in the database. I have the following scenario: 1 Database 4 Schemes different with the following owners: schemaA; proprietary dbo…
-
3
votes2
answers499
viewsHow to add one more condition in a query using Linux?
How can I add one more condition to a Join ? I have the consultation below; var consultaVeiculo = (from e in dm.Tabela_SegVeiculos join r in dm.Tabela_VeiculoRefers on e.Modelo equals…
-
3
votes3
answers149
viewsHow to generate new code from DBO
I have a table with the name Produtos in which I inserted 3 products for testing. Now I’m assembling the product registration form and I need to always generate a sequential product code from the…
-
3
votes1
answer193
viewsShow warning message without exception
I would like to display an alert message to the user without causing exception in the Database. I am using SQL Server. So I cannot use RAISERROR, nor PRINT, because it is not shown to the user.…
-
3
votes2
answers468
viewsWhat is the corresponding timestamp variable type (SQL Server) in C#?
I have a field in the database (Seqalteracao) of type timestamp and need to map it to C# (Entity Framework). What is the corresponding type in C# for this type in the bank? public **Tipo**…
-
3
votes2
answers489
viewsSqlserver Trigger after update
Let’s imagine the following scenario: CREATE TABLE invalido ( ds_valor character varying(255) ) CREATE TABLE email ( email character varying(255) ) now I need a trigger that every time I run a…
-
3
votes1
answer70
viewsHow to handle C# data from a table that is bit-like in sql server?
In visual Studio will look like this: alerta.DataHoraCadastro = dr.Get(12); How do I do that?
-
3
votes1
answer6005
viewsUsing Case When with Leftjoin
I am mounting a proc, but depending on the value of a parameter, I would like left Join to be different. I tried the kerys below: That works, but the else as null or even without the else, if the…
-
3
votes0
answers62
viewsDisplay image in Excel using binary code
I have a report on Excel where the data is displayed through a stored procedure. I have a problem because when I look for the value of the image field that is blob, it displays binary code instead…
-
3
votes2
answers1494
viewsHow to get the first result of duplicate lines?
Situation: In a table there is a list of items with their respective values invoiced in invoice. This table has a single field that varies according to the insertion of the data, can repeat all…
sql-serverasked 8 years, 2 months ago Marcelo de Andrade 7,261 -
3
votes1
answer967
viewsSql server turn a column into multiple rows
Good morning I have a table called books that has 3 fields, Code, Name and Chapters Example of content: 32 - Jonas - 4 i need after select me return the following result Codigo e Capitulo 32 1 32 2…
-
3
votes2
answers473
viewsInsert 1000 records into table with uniqueidentifier as primary key
I have to add, 1000 records in a given table. It contains the Field Name. I have the Script, which does the mass insertion. However, the primary key of this table is a uniqueidentifier(Guid()) how…
-
3
votes1
answer115
viewsProblems with select in multiple tables
I’m trying to make the conversion of a select from sql server to Dapper, as it was very big, I’m wanting to leave more lean and readable... However this appearing error in some passages SELECT…
-
3
votes1
answer1111
viewsModeling database table
I am creating a database that stores an electronic invoice - "Nfe" received. Within the items of a tax note are always linked taxes. Table example tblProdNFe_Entrada with the table…
-
3
votes5
answers1923
viewsIs it possible to update the first 100 lines in sql(server)?
UPDATE tbl_venda SET produto=1 WHERE produto=3 The problem is that there are more than 10,000 sales lines and the pc hangs. I wish it was possible to do 100 to 100, 500 to 500, so it doesn’t get…
-
3
votes1
answer301
viewsError when connecting PHP to SQL Server via ODBC Linux
I am making a connection in no windowns via php to SQL SERVER and it is going normal, in a machine where the php server is linux this giving the following error: Fatal error: Uncaught exception…
-
3
votes1
answer1101
viewsincremental vs differential backup in SQL Server
Whenever I need to set up the backup routine of an SQL Server database I confuse these two types of backup. Therefore I would like to know: What each one does? Whereas I do a full backup on Sunday,…
-
3
votes1
answer174
viewsSql Server Stored Procedures
I am starting the development of an application, basically it is a managerial control of companies. The application will issue NFC-e, Nfe, control stock, finance and etc, the database will be hosted…
-
3
votes4
answers1202
viewsWhat kind of data to use for sale ID
I have a Windows Form application developed in C# and with SQL database. One of the functions of the system is to carry out SALE for several different COMPANIES and in several different POS (point…
-
3
votes1
answer1315
viewsSQL - scope_identity() for INSERT SELECT
There is something similar to scope_identity() to return the ids created by giving a insert on the basis of a select? (insert of more than one line simultaneously). OBS: scope_identity() only one of…
-
3
votes3
answers419
viewsHow to know if a key in sql server is Identity
How do I know if a key in sql server is Identity? How do I find out? The version is 2014.
-
3
votes3
answers8033
viewsDo not repeat records in a Join
I have two tables: one with 1009 records and another 11949. When I do a Join, I have 11949 records, of which 1009 table records are repeated several times. I need to select with Join, but bring only…
-
3
votes2
answers878
viewsLimit record occurrences for each type
I need to limit the number of occurrences of each type of material I have in my database. Follow the query below with what I want to do: SELECT TOP 10 ID, NOME, TIPO FROM TB_MATERIAIS WHERE TIPO = 1…
-
3
votes1
answer809
viewsPHP Sqlserver Stored Procedure does not run correctly
Hello, I am developing an application using Laravel Framework Handler from my Backend and found the following error. My Sqlserver Express 2008 R2 database has a stored Procedure that performs a…
php sql-server laravel stored-procedures sql-server-2008asked 7 years, 11 months ago Jonatan Pietroski 109 -
3
votes2
answers4957
viewsHow to search records from the previous month?
I need to get the data from the 1st to the 30th of the previous month, I’m using this syntax. someone could help me? SELECT SUM(DIFERENÇA)as Mesanterior FROM TOTALIZADOR WHERE NID = 252 AND DATAHORA…
-
3
votes1
answer178
viewsBug script to delete entire SQL SERVER database
I have the script below to drop EVERYTHING from the database, but in one of the database I have the processing that needs this script happens a bug, for some reason it can not run the first time I…
-
3
votes2
answers505
viewshow to specify values to sort sql server
Good afternoon! Guys, I have the following query below, however, I want to order by specifying some records. Attached for example, is the query generated and I want the column Value to look like…
-
3
votes2
answers614
viewsIt takes time to count records the first time
I’m doing a stress test on an app I’m developing. I added a few million records to a table, which is what it will have in about 5 years of use. I use Entity Framework. By counting the records of a…
-
3
votes1
answer48
viewsEncrypting Function Script and Procedures in MSSQL
A doubt, I have some functions and procedures customized and I do not want my client (who has access to the bank) to be messing with their script. Does anyone know any native MSSQL way of encrypting…
-
3
votes3
answers150
viewsDatabase modeling, when it is possible to denormalize
I’m modeling a database (MSSQL) and a question has arisen. In every business rule of the clients the data is visualized vertically ex: Product, Original Price, Concurrent Price 01, Concurrent Price…
-
3
votes1
answer174
viewsGenerate number using Identity
Is it possible to generate a number before writing the record to the database? Use field identity do SQL Server 2014. Work with Delphi Berlin.