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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to insert records into a table when the primary key is nvarchar

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-08-13 : 13:07:34
Fraydoon writes "I am trying to insert records from a table1 to table2, but the problem I am facing is that the primery key on table2 is nvarchar like TEST_nnn,now how do I retive that value and add to it before I do the actual insert. Approciate all your comments.
Fraydoo"

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-08-13 : 13:38:23
You've made a poor choice for a surrogate key. If you are going to have an incrementing autonumber, you should use the built in IDENTITY property, so you won't have to worry about this.

As it standings I don't know there is a solution that wouldn't involve iterating through table1 and inserting one at a time. (bad)

If you are on SQL2k, you could use an INSTEAD OF trigger up update your PK....

Jay White
{0}
Go to Top of Page
   

- Advertisement -