Posts by Welington Luiz Sgubin • 11 points
3 posts
- 
		1 votes1 answer350 viewsA: Select with SUM until sum B is equal to or less than AFollow a possible solution to your problem. ;WITH CTE AS ( SELECT ROW_NUMBER() OVER (ORDER BY validade DESC) AS idRowNumber , codigo , qtdlote , validade FROM Lotes ) , CTE_Recursivo as ( SELECT… 
- 
		0 votes1 answer333 viewsA: How to duplicate a key’s value in SQL?The problem seems to be that it is repeating the same value in the Id field and not in the Process and Number fields. You really can’t have a PK anymore, but you can have a PK composed. There are… 
- 
		0 votes2 answers160 viewsA: SQL Procedures: Can I use a table as a parameter for a procedure?You can even mount a generic trial that can insert data into any table, but this is not something common to do. CREATE PROCEDURE [InserirUsuario] ( @tableName varchar(45) , @column1 varchar(45) ,…