By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,659 Members | 1,714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,659 IT Pros & Developers. It's quick & easy.

Convert PostgreSQL DB to MS-SQL

P: 5
Hi,
I want to convert my complete database of PostgresQL to MS-SQL.
I am some what successful in converting tables but the major problem is Functions and Triggers.


Please help.
Oct 10 '08 #1
Share this Question
Share on Google+
2 Replies


ck9663
Expert 2.5K+
P: 2,878
Post your stored proc and functions and we can try to help you convert it.Depending on the logic and business rules of your procedure and functions, it might not be able to be translated line by line. Instead, some (or all) of them might be completely re-written.

-- CK
Oct 10 '08 #2

P: 5
Post your stored proc and functions and we can try to help you convert it.Depending on the logic and business rules of your procedure and functions, it might not be able to be translated line by line. Instead, some (or all) of them might be completely re-written.

-- CK
One of the Function:

Expand|Select|Wrap|Line Numbers
  1. -- Function: sp_get_form_bag_content(bigint, bpchar)
  2.  
  3. -- DROP FUNCTION sp_get_form_bag_content(bigint, bpchar);
  4.  
  5. CREATE OR REPLACE FUNCTION sp_get_form_bag_content(in_cand_id bigint, in_payment_mode bpchar)
  6.   RETURNS SETOF typ_form_bag_content AS
  7. $BODY$
  8. DECLARE
  9.  
  10.    v_form_id_arr _int2;
  11.    v_rec form_bag%ROWTYPE;
  12.    v_return_rec typ_form_bag_content;
  13.    v_index int2;
  14.  
  15. BEGIN
  16.  
  17. update cand_preferences
  18.    set payment_mode = in_payment_mode
  19.    where cand_id = in_cand_id
  20.    and   payment_mode <> in_payment_mode;
  21.  
  22. v_index=0;
  23. for v_rec in select form_id from form_bag where cand_id=in_cand_id
  24. loop
  25.    v_form_id_arr[v_index]= v_rec.form_id;
  26.    v_index = v_index + 1;
  27. raise notice '%', v_form_id_arr[0];
  28. end loop;
  29.  
  30.  
  31. for v_return_rec in
  32. select temp2.form_id, college_name, course_list, form_cost, warning, sp_format_date(last_date,'DD-Mon-YYYY, DOW'), is_exam from (
  33. select college_id, temp.form_id, course_list, form_cost, warning, last_date, is_exam from
  34.    (    
  35.    select sp_warnings_cost.form_id, course_list, warning, form_cost from
  36.         (
  37.             select sp_cost.form_id, coalesce(sp_warnings.warning,'') as warning, sp_cost.form_cost from
  38.                 (
  39.                  select form_id,
  40.                     array_to_string(array_accum(warnings), '::') as warning
  41.                    from (
  42.                      select  *
  43.                         from sp_check_form_constraints(in_cand_id, v_form_id_arr)
  44.                     ) as sp1_warnings
  45.                    group by form_id
  46.                 ) as sp_warnings
  47.  
  48.                right outer join sp_get_forms_cost(in_cand_id, v_form_id_arr) as sp_cost on sp_cost.form_id=sp_warnings.form_id
  49.         ) as sp_warnings_cost
  50.  
  51.           left outer join sp_get_form_bag_courses(in_cand_id) sp_courses on sp_warnings_cost.form_id=sp_courses.form_id
  52.    ) as temp
  53.     inner join forms f on f.form_id=temp.form_id
  54. )temp2
  55. inner join colleges col on col.college_id=temp2.college_id
  56. loop
  57.  
  58. return next v_return_rec;
  59.  
  60. end loop;
  61.  
  62. return;
  63. END;
  64. $BODY$
  65.   LANGUAGE 'plpgsql' VOLATILE
  66.   COST 100
  67.   ROWS 1000;
  68. ALTER FUNCTION sp_get_form_bag_content(bigint, bpchar) OWNER TO postgres;
  69.  
Nov 1 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.