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
 Other Forums
 Other Topics
 seperating numbers in a column

Author  Topic 

s_a19
Starting Member

15 Posts

Posted - 2003-08-06 : 05:35:14
im using orcale,
and with sql, im trying to update a column, which has been disignated to contain numbers, in the creation of the table.

but i now need to update the column, by putting more than 1 set of numbers in, to be seperated by a column ideally.

what ive come up with so far, is below. but it wont accept it as, comma's have not been declared as a number.

update address
set cont_id=65232, 65244, 65648
where id=5014

can any1 help?

it would be much appreciated.

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-08-06 : 07:26:43
Ummmmm, a numeric column is specifically designed to hold only one numeric value. The only way for you to store multiple numbers in one column like you describe is to use a varchar data type.

Be advised that storing multiple numbers that way is EXTREMELY poor design, and will cause you more work in the long run than it would to design the table properly. You should set up a table to store each id and each cont_id value on separate rows:

CREATE TABLE AddressCont(id int not null, cont_id int not null, CONSTRAINT PK_AddressCont PRIMARY KEY(id, cont_id))

You may have to tweak that statement to work in Oracle. Your data would then look like this:
id     cont_id
5014 65232
5014 65244
5014 65648
You can query this kind of design much more easily and much faster than if you stored multiple numbers on one row.
Go to Top of Page
   

- Advertisement -