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)
 Help required SQL query(perl script required)

Author  Topic 

deepu2812
Starting Member

4 Posts

Posted - 2010-02-10 : 07:29:43
Hi Friends,

There is a urgent requirement in our project related to SQL queries. I don't have much knowledge on SQL/script. Need to write an script with the following requirements(Need to use only SQL queries in the script, we should not use PLSQL). Please can anyone help on this


Inputs to this script(perl) - Primary Key1, Associated Value1

What does it do: The script queries a table a table_t. This table has two columns Primary Key and Associated Value. The script gets Associated Value value for Primary Key passed in the query. If the output is a csv (comma separated value), then it appends Associated Value1 to the output and updates the value in the DB.. If the output is NULL, then a new row is added with the value Primary Key1, Associated Value1.



Eg.

BEFORE

Primary Key Associated Value

abc J1,J9

pqr

mno J8

xyz J3,J5




script(mno, J3);

script(pqr, J5);

script(xyz, J2);

script(efg, J6);



AFTER

Primary Key Associated Value

abc J1,J9

pqr J5

mno J8,J3

xyz J3,J5,J2

efg J6



Thanks in advace.
Deepu

Kristen
Test

22859 Posts

Posted - 2010-02-10 : 07:32:20
"we should not use PLSQL"

Is this for Oracle? (If so this site is specifically for Microsoft SQL Server, so you may not find people here who know the answer WRT Oracle)
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-02-10 : 07:35:38
Errrmmm ... OK, I've read it through now. Concatenating delimited values to columns is a really bad idea in a relational database, you should create a child table instead - so you have a "parent" table with rows for abc, pqr, mno, xyz, efg and then you can just insert rows in your "child" table for:

abc J1
abc J9
pqr J5
mno J8
mno J3
xyz J3
xyz J5
xyz J2
efg J6
Go to Top of Page

deepu2812
Starting Member

4 Posts

Posted - 2010-02-10 : 07:35:53
No. i need that for Microsoft SQL server only. We are having a SQL Query Manager, just we want use only SQL queries.
Go to Top of Page
   

- Advertisement -