Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
can anyone tell me whats up with the sql statement. I only want the values to be inserted into the temp table if they do not exist already. At the mo the values are inserted regardlessinsert into #treeSearch select [table].id, [table].title, 0from dbo.Work_sectioninner join Category on dbo.Work_section.category_id = Category.idinner join [table] on dbo.Category.table_id = [table].idwhere contains (Work_section.title,@searchTerm) and not exists (select id from #treeSearch where id = [table].id)
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2007-07-13 : 05:10:43
Are you using FREETEXT? Not? CONTAINS is a reserved keyword for FREETEXT search.
INSERT #TreeSearch SELECT t.ID, t.Title, 0FROM dbo.Work_Section AS wsINNER JOIN Category AS c ON c.ID = ws.Category_IDINNER JOIN [Table] AS t ON t.ID = c.Table_IDLEFT JOIN #TreeSearch AS s ON s.ID = t.IDWHERE s.ID IS NULL AND CONTAINS(ws.Title, @SearchTerm)
Peter LarssonHelsingborg, Sweden
rico_bano
Starting Member
35 Posts
Posted - 2007-07-13 : 05:50:38
thanks for that, but it still doesnt seem to work. s.ID always seems to be null. I really dont understand why. this should work.
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2007-07-13 : 07:57:18
Please post some sample data from all tables. Also provide expected output.Peter LarssonHelsingborg, Sweden