Skip to content

Instantly share code, notes, and snippets.

@cbaragao
Created September 29, 2023 00:06
Show Gist options
  • Save cbaragao/46963f780647083886e725ff2efcc462 to your computer and use it in GitHub Desktop.
Save cbaragao/46963f780647083886e725ff2efcc462 to your computer and use it in GitHub Desktop.
// Structure CREATE TABLE syntax.
SQL_CREATE_TABLE = LAMBDA(table_name,range, "CREATE TABLE " & table_name & " (" & CHAR(10) & REPT(" ", 5) & TEXTJOIN(", " & CHAR(10) & REPT(" ", 5), TRUE,BYROW(range,LAMBDA(r, TEXTJOIN(" ", TRUE,r)))) & CHAR(10) & ");")
// Structure IN clause with numbers.
SQL_IN_CLAUSE_NUM = LAMBDA(range,CONCAT("IN (",TEXTJOIN(", ",TRUE,range), ")"))
// Structure IN clause with text.
SQL_IN_CLAUSE_TEXT = LAMBDA(range,CONCAT("IN (", TEXTJOIN(", ",TRUE,"'"&range&"'"), ")"))
// Structure permission clause in SQL.
SQL_PERMISSION = LAMBDA(action,database,table,user, UPPER(action) & " ON [" & database & "].[dbo].[" & table & "] TO " & CHAR(34) & user & CHAR(34) & ";")
// Structure SQL SELECT statement.
SQL_SELECT_COLS = LAMBDA(range,CONCAT("SELECT", CHAR(10),TEXTJOIN(CHAR(10)&", ",TRUE,range), CHAR(10), "FROM "))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment