Showing posts with label active. Show all posts
Showing posts with label active. Show all posts

Friday, March 23, 2012

Purging Log File

How can I reset a log file for a database that is active. The file is 8
gigs. I want to restrict its growth to 50 MB and purge the contents.
How can I do this.General info on file shrinking as well as link to shrinking log file size:
http://www.karaszi.com/sqlserver/info_dont_shrink.asp
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"Ross B." <ross@.__computaught__.com> wrote in message
news:u%2382JFQDEHA.1600@.tk2msftngp13.phx.gbl...
> How can I reset a log file for a database that is active. The file is 8
> gigs. I want to restrict its growth to 50 MB and purge the contents.
> How can I do this.
>

Wednesday, March 21, 2012

Purge

Hi Everyone.

i have a big database and for each table i have Active field (N/Y) and i wanna delete all record the active N. how i can do that without delete from each tables and looking to details tables before. our database have a complex relations.

please any solution.

thanks alot.

There is no simple way. You will have to scan through the entire database and execute 'delete

' for each desired table. Since you're doing data scrubbing, it might be simpler to use DTS/SSIS to extract desired data (i.e. Y rows) from every table into new table(s). Recreate constraints as needed after that. Else you will have to track down all all referenced/referencing tables and delete accordingly.

This little old script should help finding the ref tables.

Code Snippet

if object_id('usp_findreferences','p') is not null
drop proc usp_findreferences
go

create procedure usp_findreferences
/**************************************************************************-*
*/
/* Purpose: A quick & dirty way to find ref. objects for a[ll] table[s] */
/* Author: OJ Ngo */
/* Date: 02/28/2002 */
/**************************************************************************-*
*/
@.tbname sysname=null
as
set nocount on

Print 'Referenced:'
select c1.table_name,
c1.column_name,
fkey=r.constraint_name,
referenced_parent_table=c2.table_name,
c2.column_name
from information_schema.constraint_column_usage c1 join
information_schema.referential_constraints r on
c1.constraint_name=r.constraint_name
join information_schema.constraint_column_usage c2 on
r.unique_constraint_name=c2.constraint_name
where c1.table_name=coalesce(@.tbname,c1.table_name)
order by case when @.tbname is null then c1.table_name else c2.table_name end

print ''
print 'Referencing:'
select c1.table_name,
c1.column_name,
fkey=r.constraint_name,
referencing_child_table=c2.table_name,
c2.column_name
from information_schema.constraint_column_usage c1 join
information_schema.referential_constraints r on
c1.constraint_name=r.unique_constraint_name
join information_schema.constraint_column_usage c2 on
r.constraint_name=c2.constraint_name
where c1.table_name=coalesce(@.tbname,c1.table_name)
order by case when @.tbname is null then c1.table_name else c2.table_name end
go

|||

A some help can be get from "ON DELETE {CASCADE | NO ACTION |SET DEFAULT | SET NULL} " , the option of referential constraints.But for that you have to review the relationshisps of your db. You can be helped by "Database Diagrams" in Management Studio.

Wednesday, March 7, 2012

Publisher Issues

Right i have two sql 2005 standard edition boxes within a Windows 2003 R2 active directory environment. All updates sp1 etc.

I have an mssql service account setup in AD which all the mssql services on both servers startup with.
I went to setup replication between the two servers for one db.
Firstly i setup distribution no problems no errors.

Then i went to setup the publication, all went well no errors in management studio gui but in the application event logs i got the following:

Event Type: Error
Event Source: MSSQLSERVER
Event Category: (2)
Event ID: 14151
Date: 05/10/2006
Time: 12:37:43
User: DNETWORK\mssqlservice
Computer: SGC
Description:
Replication-Replication Transaction-Log Reader Subsystem: agent SGC-MerakDB-2 failed. Executed as user: dnetwork\sqlrep. A required privilege is not held by the client. The step failed.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:
0000: 47 37 00 00 12 00 00 00 G7......
0008: 04 00 00 00 53 00 47 00 ....S.G.
0010: 43 00 00 00 0d 00 00 00 C.......
0018: 64 00 69 00 73 00 74 00 d.i.s.t.
0020: 72 00 69 00 62 00 75 00 r.i.b.u.
0028: 74 00 69 00 6f 00 6e 00 t.i.o.n.
0030: 00 00

Event Type: Error
Event Source: MSSQLSERVER
Event Category: (2)
Event ID: 14151
Date: 05/10/2006
Time: 12:37:51
User: DNETWORK\mssqlservice
Computer: SGC
Description:
Replication-Replication Snapshot Subsystem: agent SGC-MerakDB-Merak Mail DB-2 failed. Executed as user: dnetwork\sqlrep. A required privilege is not held by the client. The step failed.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:
0000: 47 37 00 00 12 00 00 00 G7......
0008: 04 00 00 00 53 00 47 00 ....S.G.
0010: 43 00 00 00 0d 00 00 00 C.......
0018: 64 00 69 00 73 00 74 00 d.i.s.t.
0020: 72 00 69 00 62 00 75 00 r.i.b.u.
0028: 74 00 69 00 6f 00 6e 00 t.i.o.n.
0030: 00 00

I've tried all sorts to get this to work, the sqlrep user is db_owner for the distro db, ive tried the sqlrep user as domain admin to see if it was a system priv issue, no luck :(

Anyone have any ideas?

Is the account dnetwork\sqlrep the same as SQL Server service account? You can try to add dnetwork\sqlrep to windows user group SQLServer2005SQLAgentUser$<MachineName>$MSSQLSERVER, SQLServer2005MSSQLUser$<MachineName>$MSSQLSERVER, then restart SQL Server service, or reboot the machine to see if the problem goes away. Also can you let us know if you have changed SQL Server service account after installation? If so, it has to be done through SQL Server configuration manager.

Thanks,

Zhiqiang Feng

|||

I tried what you suggested, no luck,

theres a service account for mssql which i named mssqlservice :)
That was set during setup and never changed.

sqlrep was created for replication only, i had already added it to the groups you suggested with no luck. The same error etc.

So i uninstalled then reinstalled mssql from scratch no problems this time.

I believe it was down to a active directory issue when we had to run gpofix it may have altered something down the line. The issue was effecting both servers so i assume it was caused by the active directory issue.

Bit strange though but its sorted now, well so far so good :)