sql server - Delete SQL looping -
I want to put only 1000 entries for each customer. I want the code given below, but does not take a loop through the client, instead of having 1000 subscribers.
Is there a way to do this in SQL? I was told that I need a cursor, but I'm not expecting.
Select the ID ID (id int) DECLARE @ Client Table (Client varchar (20)) in @clients (clientid) Select SELECT Select the INSERT @ ID from tRealtyTrac TRealtyTrac with the top 1000 id from where in the client (select client from client) DELETE trealtytrac where id is not (select ID from ID)
Is it SQL Server 2005 or later? About something like
INSERT @ID (id) from SELECT id (SELECT id, RANK), (according to the client order based on ID) from TRILTTC) T WHERE. Rank & Lt; = 1000
Comments
Post a Comment