List MS SQL Table Sizes for All Tables in a Database

by demtron on Saturday, June 06, 2009 01:56 PM

For a client's site that uses MS SQL Server, we needed a quick and easy way to see the space occupied by all tables in the database.  We found this great script here that does exactly that: 

 

declare @RowCount int, @tablename varchar(100)
declare @Tables table (
PK int IDENTITY(1,1),
tablename varchar(100),
processed bit
)
INSERT into @Tables (tablename)
SELECT TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_TYPE = 'BASE TABLE' and TABLE_NAME not like 'dt%' order by TABLE_NAME asc
declare @Space table (
name varchar(100), rows nvarchar(100), reserved varchar(100), data varchar(100), index_size varchar(100), unused varchar(100)
)
select top 1 @tablename = tablename from @Tables where processed is null
SET @RowCount = 1
WHILE (@RowCount <> 0)
BEGIN
insert into @Space exec sp_spaceused @tablename
update @Tables set processed = 1 where tablename = @tablename
select top 1 @tablename = tablename from @Tables where processed is null
SET @RowCount = @@RowCount
END
update @Space set data = replace(data, 'KB', '')
update @Space set data = convert(decimal(8,2), data)/1000
update @Space set data = data + 'MB'
update @Space set reserved = replace(reserved, 'KB', '')
update @Space set reserved = convert(decimal(8,2), reserved)/1000
update @Space set reserved = reserved + 'MB'
select * from @Space order by convert(decimal(8,2), replace(data, 'MB', '')) desc

 

 


Milwaukee SEO: Any Site Can Benefit from SEO

by demtron on Friday, March 06, 2009 04:35 PM

Based on our research, at least 95% of all business web sites have had minimal to no search engine optimization.  We're not talking rocket-science style SEO here.  We see simple things like duplicate title tags, no title tags, missing title tags, poor natural text and even broken links.

Businesses are arranged in a phone book by industry or type of business and have the relevant keywords in the section heading.  People searching in a phone book will look for the relevant business category first, then look a a business that's nearby them.

Take a look a your own website and look at what's in the title bar of the browser.  Having your company name is fine, but unless you have strong brand recognition, nobody will search for you based on your company name.  Particularly for small professional services businesses, local search can be crucial for getting traffic.  If you're an attorney in Milwaukee, Wisconsin, doesn't it make sense for your site to have Milwaukee Attorney somewhere in the title where it can be found by search engines?

Surprisingly, sometimes this is all it takes for a search engine to find and rank a page highly.  If your keyword phrases don't involve significant competition, this can launch a site right to the first page of Google search results.  On a recent site, we optimized the site for South Milwaukee Physical Therapy.  Guess what?  With that little bit of work, that site now ranks #1 for that search terms and enjoys a good amount of local traffic for that phrase.  This site now provides that business with an additional way to be found and for new customers to contact them.

If your site needs help with SEO, contact our Milwaukee SEO experts today for a free evaluation and recommendations for your site.


Sending SMTP Mail With Authentication with ASP.Net

by demtron on Monday, March 02, 2009 05:14 PM

Many web hosting now require sender authentication when sending e-mail through a relay server.  These mail servers have their security locked down.  Sometimes, localhost is an available SMTP server option, but if a relay server is required, a little extra code is also required.

ASP.Net offers the NetworkCredential class for this purposes.  By setting the NetworkCredential property in the SMTPClient object with the appropriate credentials, authentication can be passed with the request.  For example:

Dim smtp As New Net.Mail.SmtpClient
Dim m As New Net.Mail.MailMessage
m.Subject = "the subject"
m.From = New Net.Mail.MailAddress("email@domainname.com")
m.To.Add("john@demtron.com")
Dim Auth As New System.Net.NetworkCredential("email@domainname.com", "password")
smtp.UseDefaultCredentials = False
smtp.Credentials = Auth
smtp.Host = "smtp.domainname.com"
smtp.Send(m) 

Storing XML in Cookies and "dangerous Request.Cookies value" in ASP.Net

by demtron on Saturday, February 28, 2009 05:32 PM

By design, when attempting to store XML data in a cookie, the .Net Framework will raise the a HttpRequestValidationException because request validation is enabled according to Microsoft.  This is a good security mechanism to help avoid script submissions via HTTP.  Rather than turning off validation, one way to eliminate problem is to use HttpUtility.UrlEncode and HttpUtility.UrlDecode to replace suspicious characters with acceptable characters.  For example, to store an XML string to a cookie, one could use the following code:

HttpContext.Current.Response.Cookies.Set(New HttpCookie("Books", HttpUtility.UrlEncode(XMLstring)))
 


Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen · Adapted by Demtron

Bookmark and Share

Calendar

<<  July 2009  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar
Log in

Milwaukee SEO Company

Milwaukee Access Programmer/Developer

Milwaukee Website Designer and Developer



Marketing / SEO

Blog Directory
blogarama - the blog directory
TopOfBlogs
Milwaukee area SEO, SEM, ASP.Net