| Author |
Topic |
|
skumar
Starting Member
10 Posts |
Posted - 2006-08-23 : 10:46:22
|
| Hi guys,i'm a newbie in database and i need some ideas for the below mentionedproblem.i'm creating sql table from a txt file using DTS package, now once the tablegets created, i need to multiple some revenue accounts with xyz number andexpense accounts with abc number.i'm thinking more towards the line of writing a store procedure but don'thave any experience in it.PLease guide me in the right direction, also if a good book could be referedfor future; which will help me query language and this kind of issues, thatwill be GREAT!!Thanx in advance |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-08-23 : 10:50:37
|
| U can use an update statement to Update a table.If u give some sample data & expected results, v may be able to help u.Its good to have a Stored Proc. if u this is not a "One Time" task.For language references:U can use BOL (books online - ie. the help file of SQL server - u get by hitting F1 key when in Query Analyzer)Srinika |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
|
|
skumar
Starting Member
10 Posts |
Posted - 2006-08-23 : 11:01:13
|
| thanx for the quick response guys, here is a lil example of what i have and what i wanna do....prd. dep. account jan feb mar100 121 110-123 100 200 300101 121 110-124 101 201 301101 121 520-500 230 234 898101 121 750-564 999 777 898now considering that accounts that starts with 110* are expense and data for jan feb and mar needs to be multiplied by 10 and accounts starting with 520* are revenue needs to be multiplied by 50. and 750* accounts multiplied by 5this will be for every few weeks drill, so need something that could be automated or scheduled..PLease advice.. thanx |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-08-23 : 11:05:53
|
| I'll give u one, u do the restUpdate urTable set jan = jan * 10, feb = feb * 10, .... where left(account,3) = '110'Srinika |
 |
|
|
skumar
Starting Member
10 Posts |
Posted - 2006-08-23 : 13:27:10
|
| Thanx Srinika, this will do, i'll take care of the rest!!!! Please be easy on me but, how can we automate this query or schedule it to run whenever we want rather than manually launch it. |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-08-23 : 14:17:12
|
| If u automate, this will become somewhat exploding.if automated : u multiply data in a column by 10, again by 10 again by 10 .... May be u need to update only newly added stuff. If so u may need to deal with that accordingly.if still u need automation, u may create a DTS package & schedule itSrinika |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-08-24 : 02:24:29
|
How About using Case ??Update urTable set jan = Case When left(account,3) = '110' Then jan * 10 When left(account,3) = '520' Then jan *50 When left(account,3) = '750' Then jan * 5 End ... so on for feb.. Chirag |
 |
|
|
|