Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Turn comma-separated numbers in string into rows
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
-- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <A function that splits comma separated numbers in string> -- ============================================= CREATE FUNCTION [dbo].[fnSplitValues] ( @IDs nvarchar(max) ) RETURNS @SplitValues TABLE ( ID int ) AS BEGIN -- Fill the table variable with the rows for your result set DECLARE @xml xml SET @xml = N'<root><r>' + replace(@IDs,',','</r><r>') + '</r></root>' INSERT INTO @SplitValues(ID) SELECT r.value('.','int') FROM @xml.nodes('//root/r') as records(r) RETURN END GO SELECT * FROM [dbo].[fnSplitValues]('1,2,3')
View schema
fork mode
|
history
|
discussion