Questions tagged as 'sql-server'

2
answers

How to compare set of numbers with another set?

How to mount query to compare whether one set A of numbers is equal to the other, 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...
asked by 18.02.2016 / 20:10
2
answers

Time to count records the first time

I'm doing a stress test on an application that I'm developing. I added a few million records to a table, which is what it will take in about 5 years of use. I use Entity Framework. When counting records of a query , it took a long time to occur...
asked by 05.01.2017 / 11:50
1
answer

Prefixes in SQL Statement

In SQL Server it only accepts 4 prefixes in sentences, eg Select * from pmv.banco.dbo.tabela . In this case, I'm using a client linked server. However, when I refer to some table field, where I would get a prefix ( pmv.banco.dbo.tabe...
asked by 16.06.2015 / 18:16
1
answer

How to work with lock in SQL records?

I'm studying best practice to work with lock of records. What I mean is, I have several tables that can be accessed by multiple users simultaneously, but if one tries to edit the registry, for others this registry should be locked for...
asked by 26.09.2016 / 19:44
1
answer

Dynamic Query Sql Server

Gentlemen, I have the following problem: I have to set up a query that works with multiple views, for example, one of products or one of people. I'm doing some tests with this code: declare @coluna nvarchar(max) declare @variavel nvarchar(m...
asked by 24.06.2016 / 22:11
1
answer

Display subquery result and use it for calculation

I need to display a result of a subquery and use the same result to perform a calculation, is it possible to play it to a variable in MS SQL 2008 or something along those lines? example: SELECT @test = (SELECT COUNT(*) FROM [tableTest] WHE...
asked by 05.01.2015 / 17:24
1
answer

I can not perform a Select

I have a question about how I should mount SELECT for a given function. The scenario is as follows: I have 4 tables: Tab_Pessoa - Tab_Cliente - Tab_Autorizado - Tab_Cliente_Autorizado . So the Tab_Pessoa is related to...
asked by 12.01.2015 / 14:15
2
answers

Add field in position I want in sql server

Whenever I make a ALTER TABLE and add a column, that field goes to the end. In design mode, using the graphical tool of Sql Management, there is the option of Insert Column in any position, but it happens that I can not save. I have...
asked by 30.01.2015 / 12:12
2
answers

Query relationship too much for many SQL server

Hello, I have a question to make a select on SQL SERVER . I have 3 tables. They are, BOOKS, AUTHOR and BOOK_AUTOR . A BOOK_AUTOR has a foreign key of BOOKS AND AUTHOR . I need to make a id that returns all books with...
asked by 21.03.2016 / 04:44
1
answer

Trigger that calculates and updates age

I want to create a trigger that, when triggered, calculates the age of the client in each row of the table and updates if necessary. I tried the following: create trigger Atualiza_Idade on cliente for insert,update,delete as declare @i in...
asked by 05.03.2015 / 18:08