Friday, 10 July 2009

Mobile UK directory - remove

You might want to send this on to your friends in the UKMaybe you have heard about this but early next week all UK mobiles will be on a directory which will mean that anyone will be able to access the numbers. It is easy to unsubscribe but it must be done before the=0beginning of next week to make sure that you are ex directory. You could be swamped by unsolicited messages and calls. Removal is recommended by the BBC - see link below. http://news.bbc.co.uk/1/hi/programmes/working_lunch/8091621.stm

Just done this myself. Double checked it wasn't a scam and it is actually on the bbc website recommending doing this.The Directory of Mobile Phone numbers goes live next week. Apparently, all numbers including those belonging to children will be open to cold calling and the general abuse that less scrupulous telesales people subject us too.To remove your number go here. (you need your mobile phone with you to do this, they text youa code) http://www.118800.co.uk/removeme/remove-me.html

When on the site, click "Home" then "Ex-directory" this will remove you from the directory.You can remove your number from this list, and tell all your friends - especially those with children who have mobile phones. A mobile number is private and you should be able to choose who you give it to - none of us agreed to this when we signed our mobile phone contracts.

Friday, 3 July 2009

SQL start end time timing


   1:  declare @starttime datetime
   2:  set @starttime = getdate()
   3:   
   4:  --SQL
   5:   
   6:  print ' ... substring took ' + cast(datediff(ms,@starttime,getdate()) as varchar) + 'ms'
   7:  set @starttime = getdate()

Thursday, 2 July 2009

Excel data reader library in codeplex

After doing quite a bit of research, this is the best and simplest excel data reader I managed to find for the .NET environment:

http://exceldatareader.codeplex.com/

Wednesday, 1 July 2009

SQL output parameters in stored procedures

In C# add parameter of type output and obtain its value after cmd execution:


   1:  cmd.Parameters.Add("@newId", SqlDbType.Int);
   2:  cmd.Parameters["@newId"].Direction = ParameterDirection.Output;
   3:  cmd.ExecuteNonQuery();
   4:  int result = (int)cmd.Parameters["@newId"].Value;
   5:  return result;

In sproc, declare the parameter as type output:


   1:  Create procedure... (
   2:  @param1 int, etc
   3:  @newId int OUTPUT
   4:  )
   5:  begin
   6:  ...
   7:  set @newId = 123
   8:  return
   9:  end

Thursday, 25 June 2009

XYNTService: start a program automatically

http://www.codeproject.com/KB/cpp/XYNTServiceWrapper.aspx

Get database roles users principles


   1:  SET NOCOUNT ON
   2:   
   3:  --Execute two select statements.
   4:  SELECT 'IF NOT EXISTS (SELECT NULL FROM sys.sysusers WHERE [name] = ' +
   5:  QUOTENAME(dp2.[name],'''') +  ') ' + CHAR(13) + '  CREATE USER ' +
   6:  QUOTENAME(dp2.name) + ' FOR LOGIN ' +
   7:  QUOTENAME(dp2.name)
   8:  FROM sys.database_principals dp
   9:  JOIN sys.database_role_members rm ON dp.principal_id = rm.role_principal_id
  10:  JOIN sys.database_principals dp2 on dp2.principal_id = rm.member_principal_id
  11:  WHERE dp2.[name] != 'dbo'
  12:  AND dp.[name] = 'GroupNameHere'
  13:   
  14:  SELECT 'CREATE ROLE [GroupNameHere] AUTHORIZATION [dbo]'
  15:  UNION
  16:  --Returns database role members.
  17:  SELECT
  18:  'EXEC sp_addrolemember N''' + dp.[name] + ''', N''' + dp2.[name] + ''''
  19:  FROM sys.database_principals dp
  20:  JOIN sys.database_role_members rm ON dp.principal_id = rm.role_principal_id
  21:  JOIN sys.database_principals dp2 on dp2.principal_id = rm.member_principal_id
  22:  JOIN sys.server_principals sp ON sp.sid = dp2.sid
  23:  WHERE dp2.[name] != 'dbo'
  24:  AND dp.[name] = 'GroupNameHere'