Fulltext Index problems

Reply

Join Date: Oct 2008
Posts: 1
Reputation: ecejahv is an unknown quantity at this point 
Solved Threads: 0
ecejahv ecejahv is offline Offline
Newbie Poster

Fulltext Index problems

 
0
  #1
Oct 26th, 2008
Hi,

I am a beginner in Microsoft SQL. I want to create a fulltext index from a UNIQUE key. For that purpose I have the following code:

  1. CREATE FULLTEXT INDEX ON sample_table
  2. (data)
  3. KEY INDEX UQ__sample_table__59FA5E80
  4. ON Catalog_data
  5. WITH CHANGE_TRACKING OFF, NO POPULATION

This works fine. The problem is that the unique key index name is not known in advance (I got the name from the object browser) so I made a stored procedure, basically using the system "sp_helpindex" stored procedure, to get the dynamic index name. Then, if I try the follwing code:

  1. DECLARE @ui_name CHAR (100)
  2. EXECUTE S_UNIQUE_INDEX_NAME @ui_name OUTPUT
  3. CREATE FULLTEXT INDEX ON sample_table
  4. (data)
  5. KEY INDEX @ui_name
  6. ON Catalog_data
  7. WITH CHANGE_TRACKING OFF, NO POPULATION

...it does not work (Error message "Incorrect syntax near '@ui_name' ").

I have tested to print the value of the stored procedure and it is ok (same value, "UQ__sample_table__59FA5E80") and also different casting methods. Now I start to think that the variable could not be visible within the "CREATE FULLTEXT..." command context but I am not sure. Can anybody help me ?

Thanks in advance and best regards,

ecejahv
Last edited by peter_budo; Oct 29th, 2008 at 6:22 pm. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1
Reputation: ed_ward_graham is an unknown quantity at this point 
Solved Threads: 0
ed_ward_graham ed_ward_graham is offline Offline
Newbie Poster

Re: Fulltext Index problems

 
0
  #2
Dec 19th, 2008
I'm a bit of a novice myself but have you tried

  1. DECLARE @ui_name CHAR (100)
  2. EXECUTE S_UNIQUE_INDEX_NAME @ui_name OUTPUT
  3. DECLARE @SqlCmd NVARCHAR(MAX)
  4. SET @SqlCmd =
  5. 'CREATE FULLTEXT INDEX ON sample_table
  6. (data)
  7. KEY INDEX ' + @ui_name +
  8. ' ON Catalog_data
  9. WITH CHANGE_TRACKING OFF, NO POPULATION';
  10. -- now create index as a dynamic SQL command
  11. EXEC (@SqlCmd)

It almost certainly won't be the best way to do this but it should get around the problem of using a variable name for your index.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the MS SQL Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC