Wednesday, June 29, 2011

Finding text or field in T-SQL Stored Procedures, Tables, Views, etc..

I highly recommend to install this addon developed by Red Gate to SQL Management Studio.  You can search any text in all database objects (stored procedures, tables, views, triggers, functions and others).  I find it especially useful to find a stored procedure instead of using the inbuilt Management Studio filtering function. You can then double click it, and you will be redirected to the stored procedure.  I also use it when I have to rename a field from a table and have to find which stored procedures are currently listing that field in order to rename it.

I use it all the time, it's a great time-saver and it's free!



If you don't have the time to install, I used this stored procedure which would list the objects which match text that i am looking for together with the number of times found

CREATE PROCEDURE [dbo].[spr_FindText]
 @text nvarchar(max)
AS

select object_name(id) AS [Object], count(*) AS [Count]
from syscomments
where text like '%' + @text + '%'
GROUP BY object_name(id)
ORDER BY Object

Monday, June 27, 2011

Simple Pong Game in XNA C#

I wanted to try out XNA and what better way than to try it out on one of the earliest arcade video games ever?


You can download the game from here

The game still needs some polishing but it's quite playable. I guess in the next version I will add a menu in order to pause the game and maybe tweak the gameplay a bit :)


What enhancements would you do to the original Pong?

Please comment if you find any problems with the setup or with the game :)


Learning XNA 4.0: Game Development for the PC, Xbox 360, and Windows Phone 7

Sunday, June 26, 2011

Apple's work ethics

Interesting.. and I thought that Microsoft was more 'evil' than Apple.  The 2011 WORLD’S MOST ETHICAL COMPANY actually says the contrary.  There's no mention of Apple or Google in the list


Apple - Beast File from Duncan Elms on Vimeo.

The original post can be found here http://thecuriousbrain.com/?p=22685

Wednesday, June 22, 2011

Unknown Return Type

Unknown Return Type: The return types for the following stored procedures could not be detected.  Set the return type for each stored procedure in the properties window.

The error was displayed when trying to drag a stored procedure to the LINQ designer file. (DBML).

The cause of the error was the use of a temporary table inside the stored procedure (#tmpTable)

Changing the temporary table to table variable solved the problem

A more detailed explanation can be found here
Ritesh Kesharwani: Error: Unknown Return Type, The return types for the following stored procedures could not be detected….(LINQ).

Wednesday, June 8, 2011

LinqToSQL - Single method missing

'System.Data.Linq.Table< >' does not contain a definition for 'Single' and no extension method 'Single' accepting a first argument of type 'System.Data.Linq.Table< >' could be found (are you missing a using directive or an assembly reference?)

Just add

using System.Linq;

Monday, June 6, 2011

Arithmetic overflow error converting numeric to data type numeric

Today I came across the above error. Unfortunately for me, it was nested inside a cursor inside a very long stored procedure and had to debug to find the cause.  The error seems a bit strange at first as both the datatypes mentioned are numeric. It turned out to be the precision of a decimal variable.  Let me give a practical example:


DECLARE @a decimal(18,6)

DECLARE @b decimal(18,12)

SET @a = 1336200.000000

SET @b = @a -- gives ‘Arithmetic overflow error converting numeric to data type numeric’


I think that unconsciously i assumed that 18, 12 would be bigger than 18,6. The first digit represents the number of digits before and after the decimal point, while the second digit represents the number of digits after the decimal point. Thus, (18, 12) stores less digits before the decimal in this case, which results in the above error