| Author |
Topic |
|
khasim76
Starting Member
35 Posts |
Posted - 2008-09-18 : 13:51:04
|
| Create procedure usp_getInfo(@sql,@v_dt datetime, @o_company_name varchar(255)AsBegindeclare @sql varchar(500) @sql=Select 'conm' Into @o_company_name From issuer c,eq_company b Where C.issuer_id = b.company_key And valid_to >= v_dt And valid_from <= v_dt order by issuer_idEXEC ( @sql )End |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-18 : 13:53:07
|
| what are you trying to do. can you explain? |
 |
|
|
khasim76
Starting Member
35 Posts |
Posted - 2008-09-18 : 13:57:22
|
| I AM TRYING TO GENERALISE THIS QUERY BY WRITING STORED_PROCEDURE..plz help me out i am new to store proceduresselect C.issuer_id, C.issuer_name,COMPANY_VERSION,valid_to,valid_from from issuer C, eq_company b where C.issuer_id = b.company_keyAND issuer_id = 109799and valid_to >=getdate()And valid_from <=getdate() |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-18 : 14:01:36
|
quote: Originally posted by khasim76 I AM TRYING TO GENERALISE THIS QUERY BY WRITING STORED_PROCEDURE..plz help me out i am new to store proceduresselect C.issuer_id, C.issuer_name,COMPANY_VERSION,valid_to,valid_from from issuer C, eq_company b where C.issuer_id = b.company_keyAND issuer_id = 109799and valid_to >=getdate()And valid_from <=getdate()
why are you using dynamic sql for that? didnt get purpose of that. |
 |
|
|
khasim76
Starting Member
35 Posts |
Posted - 2008-09-18 : 14:05:11
|
| i am just new to store procedure i will explain in words i have a table issueri have a table company comapny has historical datai want to write a stored procedure which will bring me the company name(which is a column) as per any requested date. say on 04/23/2004. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-18 : 14:10:00
|
something like below:-Create procedure usp_getInfo@v_dt datetime, @o_company_name varchar(255)Asselect C.issuer_id, C.issuer_name,COMPANY_VERSION,valid_to,valid_fromfrom issuer C, eq_company bwhere C.issuer_id = b.company_keyAND issuer_id = 109799and valid_to >=@v_dtAnd valid_from <=@v_dtand C.COMPANY_Name=@o_company_nameGO |
 |
|
|
khasim76
Starting Member
35 Posts |
Posted - 2008-09-18 : 14:20:37
|
| Thanks for that, it ran well. but how ot test it plz let me know |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-18 : 14:26:23
|
quote: Originally posted by khasim76 Thanks for that, it ran well. but how ot test it plz let me know
exec usp_getInfo @v_dt=somedatevalue,@o_company_name=somecomapnyname in your database |
 |
|
|
khasim76
Starting Member
35 Posts |
Posted - 2008-09-18 : 14:28:36
|
| Thank you veery much |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-18 : 14:35:16
|
quote: Originally posted by khasim76 Thank you veery much
welcome |
 |
|
|
|