Advertisement
Pandaaaa906

Untitled

Jan 30th, 2023
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. declare @autoid varchar(7000)='1000907958', -- M-CCFD201030 1115-RD-0057
  2. @keyfield nvarchar(60)='autoid',
  3. @tablename nvarchar(60)='rdrecords08',
  4. @cUserId nvarchar(20)='demo';
  5.  
  6. exec('
  7. select max(cinvcode),max(cbatch),max(cfree1),max(cfree2),max(cfree3),max(cfree4),max(cfree5),max(cfree6),max(cfree7),max(cfree8),max(cfree9),max(cfree10),max(cBatchProperty1),max(cBatchProperty2),max(cBatchProperty3),max(cBatchProperty4),max(cBatchProperty5),max(cBatchProperty6),max(cBatchProperty7),max(cBatchProperty8),max(cBatchProperty9),max(cBatchProperty10)
  8. from '+ @tablename +'
  9. inner join inventory_sub
  10. on ' + @tablename+'.cinvcode=inventory_sub.cinvsubcode
  11. where ' + @keyfield + ' in (' + @autoid + ') and isnull(inventory_sub.bbatchcreate,0)=1 and isnull(cbatch,'''')<>''''
  12. group by cinvcode,cbatch,cfree1,cfree2,cfree3,cfree4,cfree5,cfree6,cfree7,cfree8,cfree9,cfree10
  13. ')
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement