Tuesday, 25 November 2014

SQL Interview Questions Links

For sql question follow these links-

http://blog.sqlauthority.com/2007/04/21/sql-server-interview-questions-and-answers-complete-list-download/

http://www.techrepublic.com/article/questions-to-ask-a-sql-server-database-developer-applicant/6126230

SQL Server 2005 Database optimization Interview questions
http://www.questpond.com/DatabaseOptimization.zip

SQL Server 2005 DTS Interview questions
http://www.questpond.com/DTSInterviewQuestions.zip
  • http://www.codeproject.com/KB/database/SQL2008InterviewQueAns.aspx
  • http://www.indiabix.com/technical/sql-server-2008/
  • http://www.pinaldave.com/sql-download/SQLServer2008InterviewQuestionsAnswers.pdf
  • http://www.careerride.com/SQLServer-Interview-Questions.aspx
  • http://blog.sqlauthority.com/2008/09/20/sql-server-2008-interview-questions-and-answers-complete-list-download/
  • http://obuyacricketacademy.com/admin/reports/SQLServer2008InterviewQuestionsAnswers.pdf
  • http://www.sqlserver-training.com/sql-server-2008-interview-questions/-
  • http://dotnetkicks.com/database/SQL_SERVER_2008_Interview_Questions_and_Answers_PDF_Download
  • http://dotnetshoutout.com/SQL-SERVER-2008-Interview-Questions-and-Answers-PDF-Download

Free text search in sql

Free text search in sql


FreeText:
  • Separates the string into individual words based on word boundaries (word-breaking).
  • Generates inflectional forms of the words (stemming).
  • Identifies a list of expansions or replacements for the terms based on matches in the thesaurus.
Syntax:
FREETEXT ( { column_name | (column_list) | * } 
          , 'freetext_string' [ , LANGUAGE language_term ] )

Example:
The following example searches for all column2 values containing the words related to Test, Data, New.
SELECT Column1
FROM Table
WHERE FREETEXT (Column2, 'New Test Data' );

Use with variable:
DECLARE @SearchWord nvarchar(300);
SET @SearchWord = N'New Test Data';
SELECT Column1
FROM Table
WHERE FREETEXT(Column2, @SearchWord);

Friday, 21 November 2014

Using a parameter in Group by clause gives error "GROUP BY expression must contain at least one column that is not an outer reference"

Suppose you have a table 'tblTest' with column named 'Col1', 'Col2'.

And you have a parameter 
Declare @param nvarchar(50)

Suppose you want to group by column with parameter.

Select @param as Parameter, Col1, Col2 , Count (Col1) from tblTest
group by @param, Col1, Col2

Above query will give error:
Using a parameter in Group by clause gives error "GROUP BY expression must contain at least one column that is not an outer reference"

Solution : You just remove @param from group by clause.
Select @param as Parameter, Col1, Col2 , Count (Col1) from tblTest
group by  Col1, Col2