You must Sign In to post a response.
  • Category: SQL Server

    When i run the Sql query shows error

    select b.stud_id, stud_name, srm_rank_code, stud_birth_place, stud_indos, stud_addr_1, stud_place, (select file_data from file_system.dbo.FileDatas where delstate<>1 and [file_id]= (select top 1 [file_ID] from stud_File_map f where f.stud_id=s.stud_id and delstate<>1 and file_map_type='PHOTO')) as 'PHOTO' (select file_data from file_system.dbo.FileDatas where delstate<>1 and [file_id]= (select top 1 [file_ID] from stud_File_map f
    where f.stud_id=s.stud_id and delstate <> 1 and file_map_type='SIGNATURE')) as 'SIGNATURE'
    from batch_course_registration a, course_registration b, student s where s.stud_id = b.stud_id and s.stud_active <> 'D' and b.cr_bill_no=a.cr_bill_no and a.bcr_batch_id= 'B8753' and b.cr_active='A'

    When i run the above query shows error as follows
    Incorrect syntax near the keyword 'as'

    The above error shows in below line as follows
    where f.stud_id=s.stud_id and delstate <> 1 and file_map_type='SIGNATURE')) as 'SIGNATURE'

    please help me what is the mistake i made in above query.
  • #756887
    hi

    The above error shows in below line as follows
    where f.stud_id=s.stud_id and delstate <> 1 and file_map_type='SIGNATURE')) as 'SIGNATURE'

    Replace like this

    The above error shows in below line as follows
    where f.stud_id=s.stud_id and delstate <> 1 and file_map_type='SIGNATURE')) as SIGNATURE


    can your provide dbscript with data i ill check and let u know.

    Name : Dotnet Developer-2015
    Email Id : kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #756888
    Hi narasiman,

    I have checked the entire it seems to Comma is missing after as 'Photo' , need to put Comma(,) after that .Please find the updated code

    select b.stud_id, stud_name, srm_rank_code, stud_birth_place, stud_indos, stud_addr_1, stud_place,
    (select file_data from file_system.dbo.FileDatas where delstate<>1 and [file_id]= (select top 1 [file_ID] from stud_File_map f
    where f.stud_id=s.stud_id and delstate<>1 and file_map_type='PHOTO')) as 'PHOTO',
    (select file_data from file_system.dbo.FileDatas where delstate<>1 and [file_id]= (select top 1 [file_ID] from stud_File_map f
    where f.stud_id=s.stud_id and delstate <> 1 and file_map_type='SIGNATURE')) as 'SIGNATURE'
    from batch_course_registration a, course_registration b, student s where s.stud_id = b.stud_id and s.stud_active <> 'D' and b.cr_bill_no=a.cr_bill_no and a.bcr_batch_id= 'B8753' and b.cr_active='A'

  • #756894
    The error is corrected. refer the below script

    select b.stud_id, stud_name, srm_rank_code, stud_birth_place, stud_indos, stud_addr_1, stud_place, (select file_data from file_system.dbo.FileDatas where delstate<>1 and [file_id]= (select top 1 [file_ID] from stud_File_map f where f.stud_id=s.stud_id and delstate<>1 and file_map_type='PHOTO')) as 'PHOTO' , (select file_data from file_system.dbo.FileDatas where delstate<>1 and [file_id]= (select top 1 [file_ID] from stud_File_map f
    where f.stud_id=s.stud_id and delstate <> 1 and file_map_type='SIGNATURE')) as 'SIGNATURE'
    from batch_course_registration a, course_registration b, student s where s.stud_id = b.stud_id and s.stud_active <> 'D' and b.cr_bill_no=a.cr_bill_no and a.bcr_batch_id= 'B8753' and b.cr_active='A'

  • #756895
    Hi,

    Replace your query with below.


    select b.stud_id, stud_name, srm_rank_code, stud_birth_place, stud_indos, stud_addr_1, stud_place, (select file_data from file_system.dbo.FileDatas where delstate<>1 and [file_id]= (select top 1 [file_ID] from stud_File_map f where f.stud_id=s.stud_id and delstate<>1 and file_map_type='PHOTO')) as 'PHOTO', (select file_data from file_system.dbo.FileDatas where delstate<>1 and [file_id]= (select top 1 [file_ID] from stud_File_map f
    where f.stud_id=s.stud_id and delstate <> 1 and file_map_type='SIGNATURE')) as 'SIGNATURE'
    from batch_course_registration a, course_registration b, student s where s.stud_id = b.stud_id and s.stud_active <> 'D' and b.cr_bill_no=a.cr_bill_no and a.bcr_batch_id= 'B8753' and b.cr_active='A'



    You missed "," after Photo column that's the reason it's throwing that error.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #756906
    Just nee to change this as

    select b.stud_id, stud_name, srm_rank_code, stud_birth_place, stud_indos, stud_addr_1, stud_place,
    (select file_data from file_system.dbo.FileDatas where delstate<>1 and [file_id]=
    (select top 1 [file_ID] from stud_File_map f where f.stud_id=s.stud_id and delstate<>1 and file_map_type='PHOTO')) as 'PHOTO'
    ,(select file_data from file_system.dbo.FileDatas where delstate<>1 and [file_id]= (select top 1 [file_ID] from stud_File_map f
    where f.stud_id=s.stud_id and delstate <> 1 and file_map_type='SIGNATURE')) as 'SIGNATURE'
    from batch_course_registration a, course_registration b, student s where s.stud_id = b.stud_id and s.stud_active <> 'D'
    and b.cr_bill_no=a.cr_bill_no and a.bcr_batch_id= 'B8753' and b.cr_active='A'

    Regards & thanks
    Arvind kumar
    Visit--blog.akumars.esoftera.in

  • #757566
    Hi,

    the problem in which you are assigning a string value as column name, thats y you are getting this problem write query like this


    select b.stud_id, stud_name, srm_rank_code, stud_birth_place, stud_indos, stud_addr_1, stud_place, (select file_data from file_system.dbo.FileDatas where delstate<>1 and [file_id]= (select top 1 [file_ID] from stud_File_map f where f.stud_id=s.stud_id and delstate<>1 and file_map_type='PHOTO')) as PHOTO (select file_data from file_system.dbo.FileDatas where delstate<>1 and [file_id]= (select top 1 [file_ID] from stud_File_map f
    where f.stud_id=s.stud_id and delstate <> 1 and file_map_type='SIGNATURE')) as SIGNATURE
    from batch_course_registration a, course_registration b, student s where s.stud_id = b.stud_id and s.stud_active <> 'D' and b.cr_bill_no=a.cr_bill_no and a.bcr_batch_id= 'B8753' and b.cr_active='A'


    then it will work properly


  • Sign In to post your comments