Guilherme Cardoso, Blog EN

.NET geek

  Home  |   Contact  |   Syndication    |   Login
  21 Posts | 0 Stories | 21 Comments | 0 Trackbacks

News

Name: Guilherme Cardoso
Age: 19
Country: Portugal


pontonetpt

NetPonto

xaml pt

Twitter





Archives

July 2011 Entries

This tip is really simple but usefull if we're concatenating strings to write a Where clause. For example: DECLARE NVARCHAR @SQL = 'SELECT ... FROM ...' IF(@IDAluno IS NOT NULL) SET @SQL = @SQL + '' WHERE [IDAluno] = ' + CAST(@IDAluno AS NVARCHAR) A better solution would be something like this: SELECT ... FROM ... WHERE ([IDAluno] = @IDAluno OR @IDAluno IS NULL) A special thanks to Paulo Moreira for the advice ;)...