Hi
In below code i am getting Incorrect Synatx near ) - +'''')'
set @query = 'select [BookId] [Book ID],BookTitle [Book],[ClosingStock], ' + @cols + ' from (select [BookID] ,BookTitle, ,(select closingstock from [View_Summary] where BookId = ''' + @BookID +'''')' from View_Calculate where (('''+@BookID+'''=''0'' OR [BookId] IN('+ cast(@BookID as varchar(Max))+')))) x pivot ( Max(Status) for StudentName in (' + @cols + ')) piv order by B';
Thanks