Questions tagged as 'sql-server'

1
answer

Grant permission to a new user in SQL Server 2014

I'm trying to assign permissions of db_datawriter and db_datareader to a new user in SQL Manager The following steps have been performed: -- criação do usuário CREATE LOGIN apostila WITH PASSWORD = 'qweQWE123!@#'; -- usuári...
asked by 18.09.2018 / 22:19
2
answers

Apply condition depending on value

In below, I need to use a condition only if the field is populated (line is commented out in script below). If not, this condition should not be part of query . Is there any way to do this via SQL ? SELECT DISTINCT SB2.B2_FILIAL,SB2.B2_C...
asked by 18.09.2018 / 14:48
1
answer

Problem with join and subqueries

I have an exercise to answer, however I do not get the complete solution, only partial ideas, the DBMS used is SQL Server. Considering the Customers, Orders, and Order Details tables, create an SQL query that brings the order ID, the order da...
asked by 19.09.2018 / 01:28
1
answer

Doubt with procedure, passing table name as parameter in sql server

I would like to create a procedure where I will pass the table name and Table Id as parameters, how could I do this? I have my example of how I would like to do DECLARE @NomeTabela VARCHAR(50) = 'Region'; DECLARE @IdDaTabela INT = 1; select...
asked by 01.09.2018 / 16:24
1
answer

Delete all records from a database except a user

I have a database that I need to delete all the records that exist in it, except a user who is in the User table with a link to another table ( AspNetUsers ). I have already made a few attempts at SSMS , but I always encounter references and...
asked by 26.11.2018 / 16:50
2
answers

Write checkbox value in sql server database

I have DataGridView and it contains checkbox , I need to write the value in the database, how can I do this insert in the database, the field in the database is like 0=false e 1=true, Only the parameter in my code is passing...
asked by 11.08.2018 / 00:41
1
answer

Copy table column A to table B sql

Good afternoon, folks, I have two tables and I need to do a SELECT to bind the code of cities that are in table B to the cities of table A. I'm using the query: select a.Cidade, b.Cidade, b.cod from tabelaA a left join tabelaB b...
asked by 08.08.2018 / 23:04
1
answer

Doubt over Encrypt Password - SQL Server

I am developing an ASP.NET MVC system, SQL Server database, which will have logins control, and to encrypt the password, I have developed the following functions and procedures: CREATE FUNCTION [dbo].[ENCRIPTA_SENHA] ( -- Add the parameter...
asked by 16.08.2018 / 16:47
2
answers

update sql relating a column with external value

Good morning, I'm having a hard time doing an SQL Server update. I have the following situation: Table 1 ID Codigo Table 2 ID Nome And I have an excel file like this: Excel Codigo Nome I need to update the Name colum...
asked by 25.09.2018 / 14:40
1
answer

Parameters for query in query in sql server

Good morning .. I have a query in sql server with date and state columns, I need to bring the result by the typed date or by the typed state or both, how can I do this right in the query in sql server. Ex if the user types only the start and...
asked by 10.10.2018 / 02:23