select to return a table

  • Thread starter Thread starter John Bailo
  • Start date Start date
J

John Bailo

I can say

SELECT "HELLO"

and it returns

HELLO

But say I want to return a table

HELLO
GOODBYE

Is there a select statement I can write?
 
Hope this will help

declare @words varchar(max)
set @words = 'hello - if you will provide more details of what you want to achieve yo will get better responses - goodbye'

declare @x xml
set @x = '<words><word>' + replace(@words, ' ', '</word><word>') + '</word></words>'

select t.w.value('.', 'varchar(100)') as word
from @x.nodes('//word') as t(w)

Mikhail Berlyant
Senior Data Architect
 
Back
Top