Archive for the ‘Uncategorized’ Category

How to remove a windows service

sc delete “Service Name”

Populating date/time tables

This code will populate a date/time table for a cube or any other purpose in SQL Server.

declare
	@start datetime,
	@end datetime,
	@date datetime,
	@hour int
select
	@start = '2011-08-01 00:00',
	@end =   '2013-01-01 00:00'
set @date = @start
while @date < @end
	begin
		set @hour = 0
		while @hour < 24
			begin
				insert into [date]([id], yeardate, monthdate, daydate, hourdate,[year], [month], [day], [hour])
				values(
					ltrim(datepart(year, @date)) + '-' + ltrim(datepart(month, @date)) + '-' + ltrim(datepart(day, @date)) + ' ' + str(@hour) + ':00',
					ltrim(datepart(year, @date)) + '-01-01 00:00',
					ltrim(datepart(year, @date)) + '-' + ltrim(datepart(month, @date)) + '-01 00:00',
					ltrim(datepart(year, @date)) + '-' + ltrim(datepart(month, @date)) + '-' + ltrim(datepart(day, @date)) + ' 00:00',
					ltrim(datepart(year, @date)) + '-' + ltrim(datepart(month, @date)) + '-' + ltrim(datepart(day, @date)) + ' ' + str(@hour) + ':00',
					datepart(year, @date),
					datepart(month, @date),
					datepart(day, @date),
					@hour)
				set @hour = @hour + 1;
			end
		set @date = dateadd(day, 1, @date)
	 end

Calculating table sizes on SQL Azure

This query will retrieve the rounded (2) size (MB) of all your tables on a SQL Azure database.

select
      sys.objects.name,
      cast(round(sum(reserved_page_count) * 8.0 / 1024, 2) as float) as size
from
      sys.dm_db_partition_stats,
      sys.objects
where
      sys.dm_db_partition_stats.object_id = sys.objects.object_id
group by
	sys.objects.name
order by
	size desc
Return top

Idea Manglar

Idea Manglar is a private held startup located in Cali, Colombia, South America. It began as an idea lab and quickly became an intuitive and innovative software developer. 1136 and Dynamic Crystal will be the first ideas going online on 2010. http://www.manglar.com