Questions tagged as 'sql-server-2012'

1
answer

How to perform a procedure with each insert?

When I am going to make a registration I want to, according to the selected category, record an id of the moderator, in the question table. select idcategoria from tb_pergunta select idmoderador,idcategoria from tb_moderador USE [BANCOTESTE]...
asked by 15.06.2015 / 18:32
1
answer

How to add primary SQL Server key?

Good morning! maybe it's simple my question, but ... I would like to know how to add primary key in a table not being at creation time (CREATE), I know that when accessing the table in "object explorer" in the "design" option it is possible with...
asked by 01.08.2018 / 14:10
2
answers

Insert Select Sql Server

Connection and Historico_ligacao I have a script that copies all data from table Ligacao to Historico_ligacao . When comparing the data between the tebalas, the historico_ligacao table is ordered differently th...
asked by 04.12.2017 / 19:52
1
answer

How to decrypt records from a SQL column - Query

Good morning! Well, how to decrypt records from a column in an SQL query. The field I want to decrypt is coluna MAX(A.Descricao) [Descrição da Última Providência] . SELECT CONVERT(DATE,T.TarData,103) [Data de Abertura], CONVERT(DA...
asked by 04.07.2017 / 16:50
1
answer

Doubt with query in SQL Server

I have the following query in SQL Server, to return me a list of cities that I need. select IDCidade as "ID", case UF when 'RS' then '1' when 'SC' then '2' when 'PR' then '3' when 'SP' then '4' when 'RJ' the...
asked by 13.12.2016 / 14:32
3
answers

Doubt - Update SQL Server 2012

When the update below is run for the first time, the field exits correctly the way I want it as below, but if I run it again, it comes out that way. What I want is that regardless of how many times the script runs, do not duplicate the month or...
asked by 16.10.2017 / 16:07
1
answer

Update with select CTE Error

I'm having a hard time performing an update with select CTE. I want to refresh the taridinclusao field. Below is the query and just below is the update that I tried to perform, however, the following error occurs: "The 'historical' derived table...
asked by 27.09.2017 / 18:54
1
answer

How to compare two dates in DatagridView and change color when VB.Net expires

My codes Private Sub CadastroDataGridView_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles CadastroDataGridView.CellFormatting If Me.CadastroDataGridView.Columns(e.ColumnIndex).Name = "DataGridViewTextBoxColum...
asked by 28.01.2016 / 13:05
1
answer

I can not give a grant in a schema

I'm working with a SQL Server 2012 database and I'm trying to assign a grant to a schema with the following command: GRANT INSERT ON SCHEMA :: trunk TO trunk And I'm having the following error: Cannot grant, deny, or revoke permissions to...
asked by 23.09.2015 / 19:48
3
answers

SQL Server subquery is always returning null. How to fix.

I have a procedure and a COMMON TABLE EXPRESSION (subquery). This my CTE does a search and offers to my query the result, my query then uses the results of it. In my Address table I have a "Complement" field that allows null values. However w...
asked by 02.12.2015 / 05:05