sql - Msg 102, Level 15, State 1, Line 27 - Incorrect syntax near ')' -
select * [h_active_students] /* section below works independently fine, generates error when used subquery */ (select view_h_active_students.stud_id, view_h_active_students.stud_last_name, view_h_active_students.stud_first_name, view_h_active_students.stud_middle_initial, cast(view_h_active_students.stud_birth date) stud_birth, view_h_active_students.stud_sex, view_h_active_students.stud_mail_street_address, view_h_active_students.stud_mail_city, view_h_active_students.stud_mail_st, view_h_active_students.stud_mail_zip_code, view_h_active_students.stud_area_cd, view_h_active_students.stud_phone_no, view_h_active_students.stud_pin, view_h_active_students.semc_yr_sem, view_h_active_students.semc_active_units, view_h_active_students.semc_finaid_active_units, view_h_active_students.semc_active_hours, view_h_active_students.semc_finaid_active_hours, h_last_name_upd = cast(replace(replace(replace(replace (view_h_active_students.stud_last_name,' ',''),',',''),'-',''),'''','') char(30)), h_first_name_upd = cast(replace(replace(replace(replace(view_h_active_students.stud_first_name,' ',''),',',''),'-',''),'''','') char(15)), h_adress_upd = cast(replace(view_h_active_students.stud_mail_street_address,',','') char(30)), /* here error pointed*/ h_stud_id = cast(left(replace(replace(replace(replace(view_h_active_students.stud_last_name,' ',''),',',''),'-',''),'''',''), 3) + left(replace(replace(replace(replace(view_h_active_students.stud_first_name,' ',''),',',''),'-',''),'''',''),1) + right(view_h_active_students.stud_id,4) char(8)) [view_h_active_students] )
sql server requires aliases on derived tables , subqueries need add alias after last parentheses:
select * [h_active_students] (select view_h_active_students.stud_id, view_h_active_students.stud_last_name, view_h_active_students.stud_first_name, view_h_active_students.stud_middle_initial, cast(view_h_active_students.stud_birth date) stud_birth, view_h_active_students.stud_sex, view_h_active_students.stud_mail_street_address, view_h_active_students.stud_mail_city, view_h_active_students.stud_mail_st, view_h_active_students.stud_mail_zip_code, view_h_active_students.stud_area_cd, view_h_active_students.stud_phone_no, view_h_active_students.stud_pin, view_h_active_students.semc_yr_sem, view_h_active_students.semc_active_units, view_h_active_students.semc_finaid_active_units, view_h_active_students.semc_active_hours, view_h_active_students.semc_finaid_active_hours, h_last_name_upd = cast( replace( replace(replace(replace (view_h_active_students.stud_last_name, ' ', ''), ',', ''), '-', ''), '''', '') char(30)), h_first_name_upd = cast(replace( replace( replace(replace( view_h_active_students.stud_first_name, ' ', ''), ',', ''), '-', ''), '''', '') char(15)), h_adress_upd = cast( replace(view_h_active_students.stud_mail_street_address, ',', '') char( 30)), h_stud_id = cast( left(replace(replace(replace(replace(view_h_active_students.stud_last_name, ' ', ''), ',', ''), '-', ''), '''', ''), 3) + left(replace(replace(replace(replace(view_h_active_students.stud_first_name, ' ', ''), ',', ''), '-', ''), '''', ''), 1) + right(view_h_active_students.stud_id, 4) char(8)) [view_h_active_students]) data -- add
Comments
Post a Comment