You must Sign In to post a response.
  • Category: .NET

    How to split one Column's data into another table

    I have question on how to split one Column's data into another table
    with 2 column.

    EG:

    Original String Field Column

    datetime
    -----------------------
    08/01/2003 14:23:52.125

    into new table as

    New Table

    Column 1 Column 2
    ---------- -----------
    01/08/2003 14:23:52
  • #498337
    Where you want to do this, in SQL Server or in asp.net ??
    Visit my blog at:

  • #498340
    in SQL Server

  • #498376
    create database TESTDB

    USE [Testdb]
    GO
    /****** Object: Table [dbo].[table1] Script Date: 04/26/2010 14:16:58 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[table1](
    [date] [datetime] NULL
    ) ON [PRIMARY]


    USE [Testdb]
    GO
    /****** Object: Table [dbo].[table1] Script Date: 04/26/2010 14:16:58 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[table2](
    [date2] [datetime] NULL,
    [time2] [nchar](10) COLLATE Turkish_CI_AS NULL
    ) ON [PRIMARY]


    select * from table1
    select * from table2
    insert into table1 values(getdate())
    insert into table2(date2,time2) select CONVERT(CHAR(10),date,102),CONVERT(CHAR(10),date,8) from table1


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.