Delete_Select where in SQL :
— Delete data from Table1
DELETE FROM Table1
FROM Table1 t1
INNER JOIN Table2 t2 ON t1.Col1 = t2.Col1
WHERE t2.Col3 IN (‘Two-Three’,’Two-Four’)
DELETE FROM Table1
FROM Table1 t1
INNER JOIN Table2 t2 ON t1.Col1 = t2.Col1
WHERE t2.Col3 IN (‘Two-Three’,’Two-Four’)
-- 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
SELECT Id, CompanyName, City, Country
FROM Supplier
WHERE Country IN ('USA', 'UK', 'Japan')
SELECT Id, ProductName, UnitPrice
FROM Product
WHERE UnitPrice NOT IN (10,20,30,40,50)
SELECT
Id, FirstName, LastName, Country
FROM Customer
WHERE Country IN
(SELECT Country
FROM Supplier)
0 comments:
Post a Comment