Tutorial by Examples

In SQL Server 2016 finally they have introduced Split string function : STRING_SPLIT Parameters: It accepts two parameters String: Is an expression of any character type (i.e. nvarchar, varchar, nchar or char). separator : Is a single character expression of any character type (e.g. nv...
Since there is no STRING_SPLIT function we need to use XML hack to split the string into rows: Example: SELECT split.a.value('.', 'VARCHAR(100)') AS Value FROM (SELECT Cast ('<M>' + Replace('A|B|C', '|', '</M><M>')+ '</M>' AS XML) AS Data) AS A CROSS apply data...
Declare @userList Table(UserKey VARCHAR(60)) Insert into @userList values ('bill'),('jcom'),('others') --Declared a table variable and insert 3 records Declare @text XML Select @text = ( select UserKey from @userList for XML Path('user'), root('group') ) --Set the XML value from ...

Page 1 of 1