zgudino / mssql-toolkit Goto Github PK
View Code? Open in Web Editor NEWHandy T-SQL snippets
Handy T-SQL snippets
Hoy en una revision SPMakeListOfExpressions
quise utilizarlo para obtener lo siguiente:
DECLARE @out nvarchar(max)
EXEC spFoo 'pre_', '1,2,3', ',', @out OUTPUT
SELECT @out
-- pre_1, pre_2, pre_3
Intente utilizando el parametro @delm
con el valor pre
:
DECLARE @out nvarchar(max)
EXEC SPMakeListOfExpressions '1,2,3', 'pre', @out OUTPUT
SELECT @out
-- '1,2,3'
Sin éxito. Intente diferentes formas @delm = ', pre'
y @delm = 'pre ,'
:
DECLARE @out nvarchar(max)
EXEC SPMakeListOfExpressions '1,2,3', ', pre', @out OUTPUT
SELECT @out
-- '1','2','3'
DECLARE @out nvarchar(max)
EXEC SPMakeListOfExpressions '1,2,3', 'pre, ', @out OUTPUT
SELECT @out
-- '1,2,3'
Ninguna con éxito.
mssql-server en su idiom no comprende HoF (Higher order Functions) ni Method Chaining tal como JavaScript, y otros lenguaje de alto nivel, hace:
const concatWithArgs = (pre, ...args) =>
args.reduce((prev, cur) => prev.concat(pre + cur), []).join(', ')
console.log(concatWithArgs('pre_', 1,2,4)) // "pre_1, pre_2, pre_4"
El procedimiento SPMakeListOfExpressions
, opino, no es ideal para esta tarea. Re-escribirlo para un propósito mas general --seria genial-- sin embargo,
Nombres candidatos podrían ser:
SPMakeList
SPMakeListOf
SPGenerateList
SPGenerateListWith
Capturar output de ejecucion SP utilizando parametro OUTPUT
es algo "tedioso".
declare @whsCodes nvarchar(255)
declare @cmd nvarchar(max)
exec SPSplitAndQuote N'02,03,04,05', @result = @whsCodes output
Otra alternativa seria simplemente por asignacion local.
declare @whsCodes nvarchar(255)
declare @cmd nvarchar(max)
exec @whsCodes = SPSplitAndQuote N'02,03,04,05'
Mismo resultado ambos, sin embargo el ultimo ahorras algunas tecleadas y es intuitivo/natural.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.