Click here to Skip to main content
15,894,825 members
Home / Discussions / Database
   

Database

 
QuestionCan a Unique Index be set on a secondary linked table field? Pin
Stryder_118-Oct-10 7:29
Stryder_118-Oct-10 7:29 
AnswerRe: Can a Unique Index be set on a secondary linked table field? [modified] Pin
Eddy Vluggen18-Oct-10 8:24
professionalEddy Vluggen18-Oct-10 8:24 
AnswerRe: Can a Unique Index be set on a secondary linked table field? Pin
rushingfly18-Oct-10 20:19
rushingfly18-Oct-10 20:19 
Questionlinked server on SQL 2005 to database on AS400 Pin
samerh17-Oct-10 20:26
samerh17-Oct-10 20:26 
AnswerRe: linked server on SQL 2005 to database on AS400 Pin
David Skelly18-Oct-10 22:27
David Skelly18-Oct-10 22:27 
GeneralRe: linked server on SQL 2005 to database on AS400 Pin
samerh18-Oct-10 22:33
samerh18-Oct-10 22:33 
QuestionSplitting a column value in to many [modified] Pin
rakeshs31217-Oct-10 18:12
rakeshs31217-Oct-10 18:12 
AnswerRe: Splitting a column value in to many Pin
RyanEK17-Oct-10 20:05
RyanEK17-Oct-10 20:05 
Hi,

I suggest you create a split function

CREATE FUNCTION [dbo].[Split]
(
  @delimited nvarchar(max),
  @delimiter nvarchar(100)
) RETURNS @t TABLE
(
  id int identity(1,1), 
  val nvarchar(max)
)
AS
BEGIN
  declare @xml xml
  set @xml = N'<root><r>' + replace(@delimited,@delimiter,'</r><r>') + '</r></root>'

  insert into @t(val)
  select 
    r.value('.','varchar(15)') as item
  from @xml.nodes('//root/r') as records(r)

  RETURN
END


Then you cross apply to your data table, pivot, then manipulate the display data.
Here is an example:

declare @tmp table (data varchar(50))
insert into @tmp (data) values ('MKG Ex Du A918731765L')
insert into @tmp (data) values ('TVN Ex Du A919721354L')
insert into @tmp (data) values ('NCL Ex Du A901713191L')
insert into @tmp (data) values ('Bin Ex Du A948606458L')

select [1] as 'SK1', [2] as 'SK2', [3] as 'SK3', substring([4], 0, 10) as 'SK3', substring([4], 10, 2) as 'SK4'
from
(
  select [1] , [2] , [3] , [4]
  from (
    select * from
    @tmp t
    cross apply dbo.Split(t.data,' ')
  ) as sourcetb
  pivot
  (max(val) for id in ([1],[2],[3],[4])
  ) as pivottable
) as t


Ryan
GeneralRe: Splitting a column value in to many Pin
Mycroft Holmes17-Oct-10 20:47
professionalMycroft Holmes17-Oct-10 20:47 
GeneralRe: Splitting a column value in to many Pin
rakeshs31219-Oct-10 23:21
rakeshs31219-Oct-10 23:21 
Questioncombine multiple rows in single row Pin
i gr817-Oct-10 17:49
i gr817-Oct-10 17:49 
AnswerRe: combine multiple rows in single row Pin
Alegria_Lee17-Oct-10 18:12
Alegria_Lee17-Oct-10 18:12 
GeneralRe: combine multiple rows in single row Pin
Blue_Boy17-Oct-10 23:15
Blue_Boy17-Oct-10 23:15 
GeneralRe: combine multiple rows in single row Pin
Alegria_Lee18-Oct-10 4:49
Alegria_Lee18-Oct-10 4:49 
AnswerRe: combine multiple rows in single row Pin
Mycroft Holmes17-Oct-10 20:43
professionalMycroft Holmes17-Oct-10 20:43 
Questionchange master collation Pin
jojoba201117-Oct-10 8:13
jojoba201117-Oct-10 8:13 
AnswerRe: change master collation Pin
Karthik. A17-Oct-10 16:59
Karthik. A17-Oct-10 16:59 
Questiondate manipulation Pin
scottichrosaviakosmos16-Oct-10 21:37
scottichrosaviakosmos16-Oct-10 21:37 
AnswerRe: date manipulation Pin
Mycroft Holmes16-Oct-10 22:19
professionalMycroft Holmes16-Oct-10 22:19 
GeneralRe: date manipulation Pin
scottichrosaviakosmos16-Oct-10 22:40
scottichrosaviakosmos16-Oct-10 22:40 
GeneralRe: date manipulation Pin
Mycroft Holmes17-Oct-10 2:02
professionalMycroft Holmes17-Oct-10 2:02 
AnswerRe: date manipulation Pin
Alegria_Lee17-Oct-10 19:01
Alegria_Lee17-Oct-10 19:01 
QuestionInsert Excel OR CSV File into MySQL OR MSSQL Database Pin
jasonmp16-Oct-10 12:17
jasonmp16-Oct-10 12:17 
AnswerRe: Insert Excel OR CSV File into MySQL OR MSSQL Database Pin
Mycroft Holmes16-Oct-10 12:37
professionalMycroft Holmes16-Oct-10 12:37 
AnswerRe: Insert Excel OR CSV File into MySQL OR MSSQL Database Pin
SimulationofSai16-Oct-10 14:31
SimulationofSai16-Oct-10 14:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.