When I create a full text index on a temporary table #Table in a query? I got Invalid name object #Table.
Is creating full text index possible in sql server?
According to the documentation, no it is not possible:
A full-text index must be defined on a base table; it cannot be
defined on a view, system table, or temporary table.
This should be clarified to point out that since the version that documentation was written for, indexed views were added to SQL Server, and documentation there states that:
one full-text index is allowed per table or indexed view
Related
In Sql Server 2008,2012 can temp tables have full text indexes?
When I run the command
CREATE FULLTEXT INDEX ON #temp (SearchTerms) KEY INDEX [ix_clustered] ON FTC;
I get
Invalid object name '#temp'
Should this work? MSDN technet doesn't list it as a limitation.
According to the documentation, no it is not possible:
A full-text index must be defined on a base table; it cannot be
defined on a view, system table, or temporary table.
This should be clarified to point out that since the version that documentation was written for, indexed views were added to SQL Server, and documentation there states that:
one full-text index is allowed per table or indexed view
I am trying to modify a stored procedure ( adding a new column in select statement) but I am getting this error:
Cannot use a CONTAINS or FREETEXT predicate on table or indexed view 'vwPersonSearch' because it is not full-text indexed.
When I try to create a Full text index on view 'vwPersonSearch' using SQL server 2008 R 2 management studio, I am getting this error:
A unique column must be defined on this table/view.
Please suggest solution to it
To create a full text index, you must specify a key index, which must be a unique, single-key, non-nullable column. An integer column type is recommended for best performance.
See http://technet.microsoft.com/en-us/library/ms187317.aspx for more details.
You may alter a column to be unique if that's one that could be or add an id of some sort to do that part.
I have an XML field which has about 5MB of data every record, but sometimes, I only need to read a small part of the XML field. As you can imagine, if I read the whole XML field and then using Linq-to-XML to parse the XML file and gather the value, it would be too slow and expensive. So I want know, is it possible to get a value directly using Linq instead of read the whole XML field?
My DB is SQL Server 2008
With the current information provided I think the best solution is to use an XML index in SQL Server.
There are four types of XML indexes:
Primary
Secondary for PATH
Secondary for PROPERTY
Secondary for VALUE
In your case it appears you know the path to the data you want, naturally a secondary PATH index seems to be the best fit.
Follow these steps to create this index:
Create primary index
create primary xml index XIX_XmlColumnName on XmlTable(XmlColumnName)
go
This will create the "base" index for your xml column, basically this means that the xml will be shredded to a hidden table and stored with values where every element is turned into one row.
Create secondary path index
create xml index XIX_XmlColumnName_Path on XmlTable(XmlColumnName)
using xml index XIX_XmlColumnName for path
go
This will create a secondary index using the path-column in the primary index (which we now know is a table).
Finally, run a (sql) query such as this in a procedure and call that from your application:
select XmlColumnName.query('/path/to/element')
from XmlTable
Granted, this is not a linq-query/solution, but imo it's always best to use a tool that fits, and not try to force it.
For more in-depth information about xml indexes, see this msdn-article.
Do index names have to be unique accross the entire sql server database, or just for that table?
For example, should I name my index: IX_OrderLoadCarrierDelivery_OrderLoadID
for the OrderLoadID column of the OrderLoadCarrierDelivery table. Or should I just name it IX_OrderLoadID
Thanks!
They have to be unique for the table or view they were created for.
Here is a reference on msdn that details this.
FTA:
index_name
Is the name of the index.
Index names must be unique within a
table or view but do not have to be
unique within a database. Index names
must follow the rules of identifiers.
I believe the convention is
IX_FieldName
No, per table.
That is, a unique (object_id, name) column pair in sys.indexes rather then just (name) in sys.objects (ignoring schema_id)
I'd also use something like IX_SingleColumn or IX_ParentTable. Adding table is superfluous unlike a default or check constraint, say, that is unique per DB
They have to be unique as everything gets stored in sysobjects with the name as key
If you use SQL management studio, it's IX_Table_Field syntax
Can MS SQL support full-text indexing for a view that connects (joins or unions) multiple databases?
Yes, absolutely. Each index will be queried individually and the results will be combined by the engine.
For example, if you've got:
DatabaseA, TableA, FieldA with a full text index
DatabaseB, TableB, FieldB with a full text index
And you have a view that includes both fields from both tables in both databases, it'll work fine when you query that view. From SQL Server's perspective, it doesn't matter whether they're in the same database or not.
If that doesn't match your scenario, try posting more detail about your challenges. Thanks!
No, not at all.
You cannot create a full text index on a table or view without an index.
You cannot create a view with a clustered index that contains Left/right joins or Unions.
You can do a full text search on a view that contains data from another database, but only if it contains a single table or inner joined tables.