Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 need to create a table and insert data

Author  Topic 

rds207
Posting Yak Master

198 Posts

Posted - 2010-02-10 : 15:07:17
hi

i need to create a table and insert the below data with a unique column in it ...

the colomns of the TableName : DW_T_ASW_SUB_SYSTEM should be :


Columns:SUB_SYSTEM_CODE integer null
SUB_SYSTEM_NAME varchar(50)null

Input Data:

SUB_SYSTEM_CODE : should be a serial #
SUB_SYSTEM_NAME :ASW
CSM5000_R3
FSM9800
GOB2000
GOBi2000
GOBi3000
MDM6600
MDM8200
MDM8200A
MDM8220
MDM9200
MDM9600
MSM3300
MSM5100
MSM6050
MSM6125
MSM6235
MSM6246
MSM6260
MSM6275
MSM6280
MSM6290
MSM6500
MSM6550
MSM6800
MSM7200
MSM7200A
MSM7225
MSM7227
MSM7500
MSM7500A
MSM7525
MSM7527
MSM7600
MSM7625
MSM7627
MSM7630
MSM8660

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-02-10 : 15:23:09
CREATE TABLE DW_T_ASW_SUB_SYSTEM
(SUB_SYSTEM_CODE int identity(1,1) -- this can't be null
,SUB_SYSTEM_NAME varchar(50)null
)

When you insert you values, don't reference the SUB_SYSTEM_CODE
INSERT INTO DW_T_ASW_SUB_SYSTEM(SUB_SYSTEM_NAME)
select yourValues

Jim




Everyday I learn something that somebody else already knew
Go to Top of Page

rds207
Posting Yak Master

198 Posts

Posted - 2010-02-10 : 16:19:11
i did this ..

CREATE TABLE DW_T_ASW_SUB_SYSTEM
(SUB_SYSTEM_CODE int identity(1,1)
,SUB_SYSTEM_NAME varchar(50)null
)

Insert into dbo.DW_T_ASW_SUB_SYSTEM(
SUB_SYSTEM_NAME)(
select distinct(sub_system) from dbo.DW_T_ASW_JOBDATA)

Output:

SUB_SYSTEM_CODE SUB_SYSTEM_NAME
2 NULL
3
4 ASW
5 CSM5000_R3
6 FSM9800
7 GOB2000
8 GOBi2000
9 GOBi3000
10 MDM6600
11 MDM8200
12 MDM8200A
13 MDM8220
14 MDM9200
15 MDM9600
16 MSM3300
17 MSM5100
18 MSM6050
19 MSM6125
20 MSM6235
21 MSM6246
22 MSM6260
23 MSM6275
24 MSM6280
25 MSM6290
26 MSM6500
27 MSM6550
28 MSM6800
29 MSM7200
30 MSM7200A
31 MSM7225
32 MSM7227
33 MSM7500
34 MSM7500A
35 MSM7525
36 MSM7527
37 MSM7600
38 MSM7625
39 MSM7627
40 MSM7630
41 MSM8660
42 ODM-Flex
43 QSC1100
44 QSC1110
45 QSC6010
46 QSC6020
47 QSC6030
48 QSC6055
49 QSC6065
50 QSC6085
51 QSC6195
52 QSC6240
53 QSC6270
54 QSC6295
55 QSC6695
56 QSD8650
57 QSD8650A
58 QST1500
59 UND1000

Why did'nt i get '1'? in the sub_system_code?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-11 : 00:08:50
what does this return?

select distinct(sub_system) from dbo.DW_T_ASW_JOBDATA

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -