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
votes1
answer83
viewsI can’t perform a Select
I’m having a question about how I should ride the SELECT for a particular function. The scenario is as follows: I have 4 tables: Tab_Pessoa - Tab_Cliente - Tab_Autorizado - Tab_Cliente_Autorizado.…
-
3
votes1
answer242
viewsHow to recover data from a query made with "ADODB.Command" object?
Based on the code below, where I can retrieve the results from ADODB.Command? This union will always work with stored Procedure, and the types of parameters that will be used are of the input and…
-
3
votes1
answer891
viewsTrigger that calculates and updates age
I want to create a Rigger that when firing calculates the customer’s age on each table row and updates itself. I tried it this way: create trigger Atualiza_Idade on cliente for insert,update,delete…
-
3
votes1
answer226
viewsHow to force an Exception when trying to delete a Master record that already contains relationship in a Child Record?
I created the following structure in SQL Server: Using Entityframework with Code-First the classes stayed that way: [Table("Master")] public class Master { [Key]…
c# sql-server entity-framework entity-framework-6 relationshipasked 9 years, 8 months ago Severo 299 -
3
votes1
answer1358
viewsSales Ranking Report
I use this SQL command to make a sales ranking SQL: SELECT VENDEDOR,SUM(TOTAL) AS GERAL FROM VENDAS GROUP BY VENDEDOR ORDER BY SUM(TOTAL) DESC; Upshot: VENDEDOR | VALOR FULANO1 | 1000 FULANO2 | 800…
sql-serverasked 9 years, 7 months ago antonio germano 31 -
3
votes1
answer380
viewsHow to insert values into a relational table when inserting a Row and get this ID?
I am building a program to insert data from excel files into a database. My database has this structure: Tables (and fields): Schedule (Id (PK), Starttime, Endtime, Dayweek, Roomid (FK), Classid…
-
3
votes1
answer967
viewsUpdate to remove a piece of a varchar field
I have a column with a varchar field. In this column has a value like this: http://dominio/img//12.jpg I want to do an update that leaves this field like this: http://dominio/img/12.jpg That // I…
-
3
votes0
answers316
viewsConnection problem with bank . mdf
I’m in the way of connecting my application C# (Windows Forms) with a database in .MDF, which is already inserted in the project folder. On the computer of the course worked normally, but at home I…
-
3
votes1
answer837
viewsPrefixes in SQL Sentence
In SQL Server it accepts only 4 prefixes in the sentences, e.g.: Select * from pmv.banco.dbo.tabela. In this case, I am using a client Linked server. However, when I reference some field of the…
-
3
votes1
answer4634
viewsHow to change an SQL Server View
I have some Views on Sql Server that were implemented by other people ,but they didn’t leave any documentation or scripts, I believe it is possible to access to change and maintain them? But I don’t…
-
3
votes1
answer1103
viewsRemote connection, C# with SQL Server (2008)
I’m a beginner in C#, and I’m trying to remotely connect my C# application to a SQL Server database that is on another PC (the PC is not on the same network, it’s my friend’s), but it’s giving…
-
3
votes2
answers608
viewsShow zero in group by SQL Server
I have a table that calls Ordem, on it has a field that represents the status of the service order (0 to 7), I need to plot a graph in Ireport, only I wanted to display in the legend the status name…
-
3
votes2
answers400
viewsC# MVC5 - Insert Fields with 4 Decimal Digits
I am making an entry in the database (SQL Server 2008) of a field configured to 'decimal(10,4)', from which I try to insert/edit, by my application C# MVC5, a field of my model of type 'decimal''.…
-
3
votes1
answer238
viewsPerformance in string filter queries vs foreign key
I’m working on a project Asp.Net MVC 5 using code first and all entities have a property called UserId of the kind string. When I will make queries filtering by a certain user(Asp.Net Identity) I do…
-
3
votes2
answers188
viewsc# query with cycles
Good people I am doing a work in using c# and my knowledge is still very limited and I am having a doubt. I have 2 tables and what I wanted to do was show the information of the 2 where the…
-
3
votes2
answers477
viewsList every month in Query or PHP?
I need to list every month within a period, including those that have not moved, example below: My Query: SELECT LEFT(B8.B8_DTVALID, 06) AS VALIDADE, SUM(B8.B8_SALDO) AS VENCIDO, 0 AS VENCENDO, 0 AS…
-
3
votes2
answers8705
viewsCompare items from different tables
I have two tables: Pessoa1 Pessoa2 +----+--------+ +----+--------+ | Id | Nome | | Id | Nome | +----+--------+ +----+--------+ | 1 | Maria | | 3 | Maria | | 2 | João | | 4 | João | +----+--------+ |…
-
3
votes1
answer6731
viewsCompare Current Line to Previous
I want in a "Test" column to define the value "S" for only in the first row of a given "code" and all the others to define the value "N" and so successively for all other codes in a SELECT, I am…
-
3
votes3
answers100
viewsWill I lose my databases if I update SQL Server 2012 Express to Standard?
I have installed an instance 2012 Express, I need to update to the Standard, but to update I need to make sure that there will be no changes in the databases.
-
3
votes1
answer111
viewsHow to restrict the time of manipulation of a table?
I would like to know a way to create a trigger in sql-server to restrict the time of handling a table between two working days (8:00 to 18:00).
-
3
votes1
answer260
viewsIncorrect information when loading bigdecimal entity
I have a table, that one of your columns is a Numeric(25,10) that will be shown the rates. But there are records that will be zeroed ( 0.0000000000 ) In my entity you own that fee, as a Bigdecimal.…
-
3
votes1
answer2466
viewsUpdate in date field updating calculated field
I have in my table a Dtbehavior field of type Datetime. Besides this I have three other fields computed as follows: DAY: (datepart(day,getdate())) MES: (datepart(Month,getdate())) YEAR:…
-
3
votes1
answer1243
viewsPass multiple parameters to an SQL query
Let’s say I have the following CPF's: 65568752877 86924355382 55317961378 82331493146 I would like to pass them as a parameter in a consultation SQL, I’m trying this way: Snippet ... " AND…
-
3
votes1
answer192
viewsSelect, by quantity, items that match conditions
I have a question when it comes time to mount a query. I’ll set up a fictional scenario to demonstrate. I have the table quantidadeQuestoes with the fields: cod_nivel cod_categoria cod_difficulty…
-
3
votes1
answer329
viewsHow to write bit information to SQL Server database?
I am developing a VB registration system and need help to record the information of a CheckBox in the SQL Server database. The column is in bit in the database, I don’t know how to pass the…
-
3
votes1
answer1703
viewsMigrate Microsoft SQL to Postgres
I need to migrate my SQL server database to Postgre-SQL, but I don’t have much database intimacy. Is there any tool that can assist in migrating? I have the backup of MS SQL . Bak is it possible to…
-
3
votes1
answer152
viewsCatch max value inside a while that is inside a cursor
My doubt is the following: I have my cursor for the interaction line by line and within it I have one while for horizontal interaction. I am trying to popular a table whose PK does not have…
-
3
votes1
answer40
viewsQuestion about query (grouping)
I have a table called ALUNO_LEGADO in SQL Server DBMS as below: Assuming there are only 5 disciplines (1,2,3,4,5) and the concepts are A = Aprovado and R = Reprovado, what condition I use to search…
sql-serverasked 9 years, 1 month ago Raphael Teodoro 335 -
3
votes1
answer159
viewsHow do I select multiple fields in the same query?
I created a dummy bank with the following structure: Below are also the numbered SQL Server scripts for database creation, if necessary. SQL Fiddle Now, what I want to do is make an appointment…
-
3
votes1
answer298
viewsQuery Union, group by and Count in the same query filtering by date range
I am not making progress in creating a query that can have UNION, GROUP BY and COUNT based on a date period in the same query. For me to achieve my goal, I need the following actions in the same…
sql-serverasked 9 years, 2 months ago Hugo 39 -
3
votes1
answer64
viewsSQL Server 2012, error executing query
Good afternoon, you guys when executing the query below: select PRO_Descricao, PED_Numero from pedido p, item i, produto pr where p.PED_Numero = i.PED_Numero and i.PRO_Codigo = pr.PRO_Codigo and…
-
3
votes1
answer1342
viewsHow to convert date to datetime?
I have the following case, I’m trying to convert the one field date for datetime using the update update tb_RHContratos set DtCadastro = cast(DtCadastro as datetime) But some of the date this does…
-
3
votes3
answers533
viewsHow to point the Entity framework to another database?
Hello, My Entity Framework always points to my local database...I have tried to change the string Connection by passing the data of a database that is on another server and nothing happens it keeps…
-
3
votes1
answer92
viewsSQL Server Rotary Records
I would like to know how to select records rotationally from a table. For example I have a table called disclosure and I want the records to be selected in such a way that today brings the element…
-
3
votes1
answer1218
viewsHow to run a query with large data volume?
Is there any way to run a file with a large volume of data without being direct on SQL Server 2014 Management Studio, because I try to open to run and get the following error: Cannot run script.…
sql-serverasked 9 years ago Marco Souza 12,304 -
3
votes2
answers939
viewsQuery returns empty using PHP with PDO and MS Sqlserver
I’m migrating a system made in ASP to PHP. However, I’m having trouble making a query using PDO: Search.php class Busca extends Conexao { private $termo; public function setTermo($termo) {…
-
3
votes4
answers8633
viewsSQL query comparing two fields of the same table
I have a table in SQL Server and I’m having trouble making a query. I have a table like this: alunos ra nome serie cod_curso 23 joão 1 EI 23 joão 2 EI 23 joão 3 EI 44 maria 5 EF 44 maria 6 EF 61…
-
3
votes1
answer1506
viewsHow to make an hour comparison in sql
I have a sql query : select HORA_FECHAMENTO, --campo char no recebendo a hora no formato 18:00 CONVERT(VARCHAR(11),GETDATE(),114) as HORA_ATUAL from TB_ESTRACAO where IDEXTRACAO = 4 I want to…
sql-serverasked 8 years, 10 months ago Harry 3,805 -
3
votes2
answers71
viewsSelect random with Sqlserver (mssql)
What is the correct way to make an unspecified (random) selection using PHP + Sqlserver, since Microsoft queries do not accept ORDER BY RAND() from MYSQL. Using MYSQLI would be like this: $sql…
-
3
votes1
answer546
viewsWorking with high processing load in a table
What are the possible strategies of database modeling in a scenario where one has a specific table that receives a gigantic load of statements of insert, update and delete, in addition to high data…
-
3
votes1
answer128
viewsMake query not showing some results
I have a table of CPF where the CPF’s registered. I need to make a SELECT where display all registered Cpfs, least 3 CPF’s. Something like: SELECT * FROM cpf WHERE cpf_id <>…
-
3
votes2
answers4180
viewsCreate a script to check if the table has a primary key
I need to create a script to check if a table has primary key, if not, is added to primary key. I found this way to make the script, nas did not understand where it takes the name of this table…
-
3
votes1
answer47
viewsJoin SQL SERVER Selects
I have the following selects, but need to be returned these data together, joining the selects someone suggests something? SELECT COUNT(numero_parcela) as 'total_parcelas', SUM(valor_original) as…
sql-serverasked 8 years, 9 months ago Thiago Motta Barboza 382 -
3
votes1
answer83
viewsHow to perform an arithmetic operation without ordering it in GROUP BY
Having the following SELECT consulting a dynamic table from a subselect, I get the result of the query correctly but with records divided in the following example: cod_representante | ... |…
-
3
votes1
answer251
viewsWhich PHP extension should I use with SQL Server 2000?
I am trying to connect to SQL Server 2000 database using PHP PDO SQLSRV, but when accessing index return me the catch() with the following error SQLSTATE[08001]: [Microsoft][SQL Server Native Client…
-
3
votes3
answers325
viewsData types in SQL Server 2012 and HTML forms with PHP: date and monetary values
How can I put a mask in an HTML form, in the date and monetary value fields, then send this data to the database without having to convert the strings into types date and money? Explain: I have a…
-
3
votes2
answers619
viewsStored Procedure for log data insertion
I need to create a Stored Procedure in my SQL Server database. The purpose of this Stored Procedure is to record data in a Log table, which has three fields: date, time, ID of who logged in. Date…
-
3
votes4
answers15818
viewsAdd and Subtract value from same SQL column
I have a table with the following data: +---------------------------+ | Cod_Art | Armazem | Quant | +---------------------------+ | 11430001 | 1 | 0 | | 11430001 | 2 | 3 | | 11430001 | 3 | 0 | |…
-
3
votes2
answers3629
viewsError trying to remove a temporary table
I have a service where I load data from an ERP into a DW. The source of the data is SQL Server 2008 R2 10.50.1600.1 and the target server MS SQL Server 2008 10.0.5512.0 SP3. The service performs a…
-
3
votes3
answers2863
viewsCopy data from one table to another without entering field by field
Does anyone know the SQL command that copies the data from one table to another table, without having to clarify all the fields of the original table? I know there is a way but I forgot how it does…