Created
November 12, 2021 15:48
-
-
Save obeduri/b96ae919982728c660b5a087b9364c15 to your computer and use it in GitHub Desktop.
SQL Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- GET THE MAX ID ASSIGNABLE POSSIBLE IN A TABLE | |
SELECT max(id) AS id FROM :TABLE; | |
-- DYNAMIC QUERIES | |
SELECT * FROM ( | |
SELECT * FROM students S | |
JOIN cursos ON s.cursoId = c.cursoId | |
) WHERE (contidion = :condition OR :condition = 0) | |
CREATE PROCEDURE SPWITHTEMPTABLES | |
@VAR1 TYPE(QTY), | |
@VAR2 TYPE(QTY), | |
@VAR3 TYPE(QTY) | |
AS | |
SET NOCOUNT ON | |
Declare @tabla2 Table ( | |
FIELD1, | |
FIELD2, | |
FIELD3, | |
FIELD... | |
) | |
Insert Into @tabla | |
SELECT * FROM TABLE_NAME | |
Declare @tabla2 Table ( | |
FIELD1, | |
FIELD2, | |
FIELD3, | |
FIELD... | |
) | |
Insert Into @tabla2 | |
SELECT * FROM TABLE_NAME | |
SELECT * FROM @TABLE1 | |
UNION ALL | |
SELECT * FROM @TABLE2 | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment