declare @db_name varchar(100) = 'dbname';https://gist.github.com/szunyog/7941990
declare @kill_commands varchar(max) = '';
select
@kill_commands=@kill_commands+'kill '+convert(varchar(5),spid)+';'
from master..sysprocesses
where
spid <> @@SPID -- avoid to kill the current process
and dbid=db_id(@db_name)
print 'Executing: ' + @kill_commands;
exec (@kill_commands);
Szunyog's Blog
Small tips and tricks from the IT world.
Killing other processes connected to an MSSQL database
Lists all foreign keys (source and ref columns) in a MSSQL database
This script lists all foreign key references in a MSSQL database, using system tables:
SELECThttps://gist.github.com/szunyog/7579122
t.name AS TableWithForeignKey,
c.name AS ForeignKeyColumn,
r.name AS ReferencedTable,
rc.name AS ReferencedColumnName
FROM sys.foreign_key_columns AS fk
inner join sys.tables AS t
on fk.parent_object_id = t.object_id
inner join sys.columns AS c
on (t.object_id = c.object_id
AND fk.parent_column_id = c.column_id)
inner join sys.tables AS r
on fk.referenced_object_id = r.object_id
inner join sys.columns AS rc
on (r.object_id = rc.object_id
AND rc.column_id = fk.referenced_column_id)
ORDER BY
TableWithForeignKey,
fk.constraint_column_id
Django email setup on Hostgator
On Hostgator it is possible to run Django applications with FastCgi, but it has only sendmail as email back-end which is not included in Django.
Hopefully there is a snipets to resolve this limitation. You just needed to change the path of the sendmail file and it was ready to run. The location of sendmail is "/usr/sbin/sendmail" on our Hostgator server.
And the email backend should be configured in your settings.py by adding the following line:
Hopefully there is a snipets to resolve this limitation. You just needed to change the path of the sendmail file and it was ready to run. The location of sendmail is "/usr/sbin/sendmail" on our Hostgator server.
And the email backend should be configured in your settings.py by adding the following line:
EMAIL_BACKEND = 'sendmail.EmailBackend'
Dajngo app unicode JSON repsonse
If your django application has unicode data, and your view uses jquery and JSON response, do not forget to specify the encoding for the mimetype:
return HttpResponse(simplejson.dumps(your_data),
mimetype='application/json; charset=utf-8')
Open OpenOffice documents from a network share using nautilus
Under my gnome desktop, I had a problem when tired to open documents from a network share with OpenOffice. When I tired the spalsh screen appeared, but the document did not open.
After some searching I found the debian squeze has a package openoffice.org-gnome. I was curious what is the difference between the standard openoffice.org package and this one. Soon I found it's home page: http://projects.gnome.org/ooo/
Almost the first line said:
I installed and the problem went away.
After some searching I found the debian squeze has a package openoffice.org-gnome. I was curious what is the difference between the standard openoffice.org package and this one. Soon I found it's home page: http://projects.gnome.org/ooo/
Almost the first line said:
Gnome-VFS - G/OO.o allows transparent access to allow documents to be loaded / saved from a range of Gnome VFS backends, eg. Samba shares.
I installed and the problem went away.
Subscribe to:
Posts (Atom)