Jump to content

Calling Sql Dba Experts


Recommended Posts

Posted

[quote name='GatisKandis' timestamp='1382111277' post='1304434117']
rough ga raskuntu poya....dint even execute in my machine if it runs wihtout error then it works else do tell me the error...tran statements peti chusko if this is working or not lekapote motham data kampu itadi..

Bhayya actually 20 tables ki sperate gaa rasyina like delete from tbl_audit_agjustment where auditdate < date add (yy,1,getdate()) run chesthe table lo motham table got deleted... Aa Where clause lo we shd change bhayya such that only date related to previous yr delete kavali current data undali

declare @tablenames table(tablename varchar(200)) --ee table lo motham table names save chestunna
declare @deletestatement -- deentlo delete statement untadi..

insert into @tablenames(tablename)
SELECT name
FROM sys.Tables

select * from @tablenames

while(select top 1 @currenttablename = tablename from @tablenames)
begin
set @deletestatement = 'DELETE FROM' +@currenttablename+ 'WHERE auditdate < dateadd(yy,1,getdate())'
exec @deletestatement
delete from @tablenames where tablename = @currenttablename
end
[/quote]

  • Upvote 1
Posted

Bhayya actually 20 tables ki sperate gaa rasyina like delete from tbl_audit_agjustment where auditdate < date add (yy,1,getdate()) run chesthe table lo motham table got deleted... Aa Where clause lo we shd change bhayya such that only date related to previous yr delete kavali current data undali

Posted

[quote name='LallaayiPaata' timestamp='1382114771' post='1304434587']
Bhayya actually 20 tables ki sperate gaa rasyina like delete from tbl_audit_agjustment where auditdate < date add (yy,1,getdate()) run chesthe table lo motham table got deleted... Aa Where clause lo we shd change bhayya such that only date related to previous yr delete kavali current data undali
[/quote]

Gatis pyna issue chudu maama............this is Lallayyipaata..........[img]http://lh3.ggpht.com/--o7mXz3u-j4/T9VVBGzBJAI/AAAAAAAAGo0/kmj8a1-XW2g/s150/PK-1.gif[/img]

Posted

Thanks Gatis n Ghazni........Work done ata.............

Posted

meeting ninchi epude came andhuke kada dateadd lo -1 petta this is substract 1 year to the current year and delete the previous...
[quote name='LallaayiPaata' timestamp='1382114771' post='1304434587']
Bhayya actually 20 tables ki sperate gaa rasyina like delete from tbl_audit_agjustment where auditdate < date add (yy,1,getdate()) run chesthe table lo motham table got deleted... Aa Where clause lo we shd change bhayya such that only date related to previous yr delete kavali current data undali
[/quote]

Posted

orini -1 place lo +1 petina...dateadd lo [img]http://lh3.ggpht.com/--o7mXz3u-j4/T9VVBGzBJAI/AAAAAAAAGo0/kmj8a1-XW2g/s150/PK-1.gif[/img]
[quote name='LallaayiPaata' timestamp='1382116203' post='1304434742']
Gatis pyna issue chudu maama............this is Lallayyipaata..........[img]http://lh3.ggpht.com/--o7mXz3u-j4/T9VVBGzBJAI/AAAAAAAAGo0/kmj8a1-XW2g/s150/PK-1.gif[/img]
[/quote]

×
×
  • Create New...