| Author |
Topic  |
|
|
teamjai
Starting Member
India
33 Posts |
Posted - 10/09/2012 : 05:25:46
|
Dear all,
I am using SQL server 2008. I am trying to insert data into a tables, I don't know how to insert number in the below format. please help me. Table 1: Seq.No -------- 1:1 2:2 3:3 . . n:n
Table 2:
Seq.No ------- 1:1 1:2 . . 1:n
|
|
|
sunitabeck
Flowing Fount of Yak Knowledge
5152 Posts |
Posted - 10/09/2012 : 06:50:16
|
If the column into which you are inserting the number has a numeric data type (INT, BIGINT etc.), you cannot insert a value such as 1:1 into that column. To be able to do that, the column has to be of character type (such as VARCHAR, NCHAR etc.).
It may be better if you do not try to make the column character type. Instead, one approach you might consider is to have two columns, both of numeric type - for example, SeqNo column and SubSeqo column. Then, you would insert the part to the left of the colon in the Seq No column and the part to the right in the SubSeqNo column. |
 |
|
|
sql-programmers
Posting Yak Master
USA
189 Posts |
Posted - 10/09/2012 : 06:51:50
|
Hi,
You can not store values like 1:1, 1:2...n:n in the number field.
You can achieve if you define as varchar field in the table. When you insert new record you need to get maximum value
of the sequence or sub-sequence number then concatenate the both and finally store the value in the varchar field.
It more difficult....
But if you would like this field to make as primary field.
This is not a normalization method. instead of store like 1:1, 1:2 define two columns in the table to store
the sequence no and sub-sequence number with primary key.
It will be more comfortable and normalized.
SQL Server Programmers and Consultants http://www.sql-programmers.com/ |
 |
|
| |
Topic  |
|
|
|