Pages

Banner 468 x 60px

 

Wednesday, March 8, 2017

Delete where in SQL Server

1 comments
-- Delete data from Table1
DELETE Table_2
FROM Table_2 t2
INNER JOIN Table_1 t1 ON t1.journalid = t2.journalid
WHERE t1.status IN ('posted')
GO
 
-- Delete data from Table1
DELETE [BSPLive].[dbo].[INVENTJOURNALTRANS]
FROM [BSPLive].[dbo].[INVENTJOURNALTRANS] t2
INNER JOIN [BSPLive].[dbo].[INVENTJOURNALTABLE] t1 ON t1.journalid = t2.journalid
WHERE t1.POSTED IN ('0') and t1.JOURNALID like 'M%'
GO



Update table_name set BIT_LEDGERDIMENSION = Replace(BIT_LEDGERDIMENSION,'50','51') where BIT_LEDGERDIMENSION Like '50%' and BIT_Location = 'M12' and JournalNum like 'R%'

DELETE [BSPLive].[dbo].[LEDGERJOURNALTRANS]
FROM       [BSPLive].[dbo].[LEDGERJOURNALTRANS] t2
INNER JOIN [BSPLive].[dbo].[LEDGERJOURNALTABLE] t1
ON t1.journalnum = t2.journalnum
WHERE t1.POSTED IN ('0') and t1.CREATEDBY = 'admin' and t1.journalname = 'GJPCP'

/****** Script for SelectTopNRows command from SSMS  ******/
SELECT [JOURNALID], recid
  FROM [BSPLive].[dbo].[INVENTJOURNALTRANS]
  where cast(recid as varchar)like '%.%'
  and recid < 10000

SELECT [BSPLive].[dbo].[INVENTJOURNALTRANS].[JOURNALID], [BSPLive].[dbo].[INVENTJOURNALTRANS] .recid
  FROM [BSPLive].[dbo].[INVENTJOURNALTRANS]
  inner join [BSPLive].[dbo].[INVENTJOURNALTABLE]
  on [BSPLive].[dbo].[INVENTJOURNALTABLE].JOURNALID = [BSPLive].[dbo].[INVENTJOURNALTRANS].JOURNALID
  where cast([BSPLive].[dbo].[INVENTJOURNALTRANS].recid as varchar)like '%.%'
   and [BSPLive].[dbo].[INVENTJOURNALTRANS].recid < 10000
   and [BSPLive].[dbo].[INVENTJOURNALTABLE].POSTED = 0

DELETE [BSPLive].[dbo].[INVENTJOURNALTRANS]
FROM [BSPLive].[dbo].[INVENTJOURNALTRANS] t2
INNER JOIN [BSPLive].[dbo].[INVENTJOURNALTABLE] t1 ON t1.journalid = t2.journalid
WHERE cast(t2.recid as varchar)like '%.%'
   and t2.recid < 4000
   and t1.POSTED = 0

select t2.JOURNALID, t2.RECID FROM [BSPLive].[dbo].[INVENTJOURNALTRANS] t2
INNER JOIN [BSPLive].[dbo].[INVENTJOURNALTABLE] t1 ON t1.journalid = t2.journalid
WHERE cast(t2.recid as varchar)like '%.%'
   and t2.recid < 4000
   and t1.POSTED = 0

select t2.JOURNALID, t2.RECID FROM [BSPLive].[dbo].[INVENTJOURNALTRANS] t2
WHERE t2.RECID like '%761%'

delete from [BSPLive].[dbo].[INVENTJOURNALTRANS]
where [BSPLive].[dbo].[INVENTJOURNALTRANS].JOURNALID = 'M3BSP02R24728'

select journalid, recid from  [BSPLive].[dbo].[INVENTJOURNALTRANS]
where  [BSPLive].[dbo].[INVENTJOURNALTRANS].RECID like '%.%'
       and [BSPLive].[dbo].[INVENTJOURNALTRANS].recid < 4000

delete from [BSPLive].[dbo].[INVENTJOURNALTRANS]
where  [BSPLive].[dbo].[INVENTJOURNALTRANS].RECID like '%.%'

       and [BSPLive].[dbo].[INVENTJOURNALTRANS].recid < 4000

1 comments:

Anonymous said...

Abaixo falamos sοbre uso ԁe aplicativos no smartphone.

A financial dimension value is based on the record and has been used on a transaction. You cannot delete the record

  SOLUTION delete in table DimensionAttributeLevelValue base on Bank Account  :  and Delete the Bank Account FINISH