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)
 Data Manipulation

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-09-12 : 07:38:31
Zee writes "Goal: Copy the contents of x amount of columns from say TableA into various other existing tables.

Method: Create an SP to retrieve each row in TableA and store each column data into a variable then, take that column and insert into a different existing table but ensuring that there are no duplicate records.

Problem: While retrieving the row, one of the columns (say ColumnA) has comma separated values. Each CSV data within ColumnA needs to be verified for duplicate records in say TableB. Once verified, then it needs to be entered into TableB as new record(s). For example, if "Cat, Dog, Tiger" is the value and only "Cat" and "Dog" are present, then "Tiger" needs to be entered as a new entry.

Database Server: MSSQL 2000

Some help would be appreciated!"

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-09-12 : 09:18:40
use the split function to split the CSV.
The function returns a table that you can compare to or insert into other tables.
i use this one:
http://weblogs.sqlteam.com/mladenp/archive/2005/08/01/7421.aspx
under 18

Go with the flow & have fun! Else fight the flow
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-12 : 09:21:09
you need to use Dynamic SQL or split function
Refer this for split function
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -