Posts by Levi Macedo • 57 points
6 posts
-
0
votes1
answer291
viewsA: Insert error with FK
When creating the table CREATE TABLE Clients ( idCliente INT NOT NULL IDENTITY (1, 1) CONSTRAINT Pk_clients PRIMARY KEY (idCliente), Named client VARCHAR(255) ) with IDENTITY (1, 1) Newid() will not…
-
4
votes6
answers17379
viewsA: How to improve reading performance of a SQL Server database?
By updating your database statistics, you can achieve improved performance as well. The first execution may take a while, but it’s worth it. Just run the command below in a query SQL: use…
-
1
votes3
answers164
viewsA: Return the id of a table in another table
The ideal would be to create a column id_cliente on the table of CLIENTE_APROVADO and migrate as follows: update CA set cA.id_cliente = CC.IDCLIENTE from CLIENTE_APROVADO CA WITH(NOLOCK) inner join…
-
0
votes4
answers1841
viewsA: Does the order of the WHERE clauses interfere with performance?
Yes, try to always put as the first clause reference dates for very large queries.. you will earn enough performance.
-
-2
votes5
answers25936
viewsA: How to pass a list of values to a Stored Procedure?
CREATE PROCEDURE [dbo].[pr_lista_produtos] ( @IDS VARCHAR(MAX) ) AS BEGIN SET NOCOUNT ON create table #ProdutosIDs (id int) Declare @ProductsSQL nvarchar(max); Select @ProductsSQL = 'Insert into…
-
1
votes1
answer1278
viewsA: How to put an SQL command in a variable
Thus: DECLARE @COMANDOSQL VARCHAR(MAX) SET @COMANDOSQL = 'WITH DB_CPU_Stats AS (SELECT SUM(total_worker_time) AS [CPU_Time_Ms] FROM sys.dm_exec_query_stats CROSS APPLY (SELECT CONVERT(int, value) AS…