• Talk about sparse details. It would be helpful if in the future you could provide more details. At the very least declare the variables.

    Once I declared the variables so I could start looking it was pretty obvious.

    declare @OrgName varchar(max), @OrgID int, @dbname varchar(50)

    Then just start removing stuff from your code to isolate the issue.

    The culprit is here.

    CONVERT(varchar(20),+ 'pol_id)'

    That will get rid of the syntax error but...

    Actually this script is a part of my program that uses cursors concept

    Cursors are horribly slow and should be used in certain situations. I can't tell from your snippet but I doubt that what you doing here is one of those situations. If you want to really improve your code, take a look at the first link in my signature about best practices, post ddl and sample data along with desired output and we can help you get rid of that nasty cursor.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/