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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to insert number ?
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yak Posting Veteran

52 Posts

Posted - 10/09/2012 :  05:25:46  Show Profile  Reply with Quote
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:

Table 2:


Flowing Fount of Yak Knowledge

5155 Posts

Posted - 10/09/2012 :  06:50:16  Show Profile  Reply with Quote
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.
Go to Top of Page

Posting Yak Master

190 Posts

Posted - 10/09/2012 :  06:51:50  Show Profile  Visit sql-programmers's Homepage  Reply with Quote

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
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000