which way is better and how - plz

Results 1 to 2 of 2

Thread: which way is better and how - plz

  1. #1
    Join Date
    Dec 1969

    Default which way is better and how - plz

    Hi<BR><BR>I had two tables. they are temp_cop and www_cop . In table temp_cop i store course_codes which can be upto 6 and same thing with steam_codes. I can store upto 6 coursecodes or stream codes in this table. Pref_num is the field which stores how many course_codes entered. i mean 1,2,3.. upto 6. <BR><BR>Now what i need is from temp_cop table i need to copy those course_codes into www_cop table into different fields i.e. From one field different rows to one table different fields.<BR><BR>eg:<BR>temp_cop.course_codes -&#062; www_cop.course_code_1, www_cop.course_code_2,www_cop.course_code_3,www_co p.course_code_3 .. etc. <BR><BR>same thing i have to do with stream codes. <BR><BR>I have no idea how to do this. Please let me know which way is better or If any one of you know please do help me. I am copying the table structure for you.<BR> <BR><BR>(1)<BR><BR>CREATE TABLE [dbo].[temp_cop] (<BR> [Pref_Num] [int] NULL ,<BR> [ref_Num] [int] NULL ,<BR> [course_codes] [nvarchar] (10) NULL ,<BR> [Stream_codes] [nvarchar] (5) NULL ,<BR> [entered_date] [datetime] NULL ,<BR>) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]<BR>GO<BR><BR>(2)<BR><BR>CREATE TABLE [dbo].[www_cop] (<BR> [ref_num] [int] NOT NULL ,<BR> [date_entered] [char] (20) NOT NULL ,<BR> [course_code_1] [char] (6) NOT NULL ,<BR> [course_code_2] [char] (6) NOT NULL ,<BR> [course_code_3] [char] (6) NOT NULL ,<BR> [course_code_4] [char] (6) NOT NULL ,<BR> [course_code_5] [char] (6) NOT NULL ,<BR> [course_code_6] [char] (6) NOT NULL ,<BR> [stream_code_1] [char] (3) NOT NULL ,<BR> [stream_code_2] [char] (3) NOT NULL ,<BR> [stream_code_3] [char] (3) NOT NULL ,<BR> [stream_code_4] [char] (3) NOT NULL ,<BR> [stream_code_5] [char] (3) NOT NULL ,<BR> [stream_code_6] [char] (3) NOT NULL ,<BR> <BR>) ON [PRIMARY]<BR>

  2. #2
    Join Date
    Dec 1969

    Default VERY bad table design...

    ...do NOT do it this way.<BR><BR>And WHY would you store a field named date_entered as a CHAR field of all things???? Never heard of DateTime fields???<BR><BR>You need *another* table and change the www_cop table.<BR><BR>Something like this:<BR> CREATE TABLE [dbo].[www_cop] (<BR> [ref_num] INT NOT NULL , -- ref_num should be a PRIMARY KEY<BR> [date_entered] DATETIME NOT NULL <BR> )<BR>and<BR> CREATE TABLE [dbo].[www_cop_courses] (<BR> ref_num INT, -- ref_num is foreign key to www_cop table<BR> course_code char(6),<BR> stream_code char(3)<BR> )<BR><BR>And now you create 6 www_cop_courses records for each www_cop record.<BR><BR><BR><BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts