Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am creating spatial index on sqlserver table.

CREATE SPATIAL INDEX [SIndex_udt_cell_SP_GEOMETRY] ON [udt_cell] 
(
    [SP_GEOMETRY]
)USING  GEOMETRY_GRID 
WITH (
BOUNDING_BOX =(80.0713, 26.389581, 88.169199, 29.974694), GRIDS =(LEVEL_1 = MEDIUM,LEVEL_2 = MEDIUM,LEVEL_3 = MEDIUM,LEVEL_4 = MEDIUM), 
CELLS_PER_OBJECT = 16, PAD_INDEX  = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO

CREATE TABLE [udt_cell](
    [ID_PK] varchar(9) not null,    
    [PRINX] [int] NOT NULL,
    [STYLE] [varchar](254) NULL,
    [SP_GEOMETRY] [geometry] NULL,
 CONSTRAINT [PK_udt_cell] PRIMARY KEY CLUSTERED 
(
    [ID_PK] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
)

I am getting error :

Implicit conversion from data type varchar to binary is not allowed. Use the CONVERT function to run this query.

Why am i getting this error although the column on which index is being created is geometry type? I have changed the primary key from varchar to int too.

**

share|improve this question

migrated from stackoverflow.com Oct 17 '13 at 20:00

This question came from our site for professional and enthusiast programmers.

1  
It seems ok to me. Are you sure the CREATE INDEX is throwing this error and not a query before or just after it (in the script)? –  ypercube Oct 17 '13 at 20:05
    
@ypercube I only have create index statement. I tried using ssms as well but the same error. I created the table using "select * into new_tbl from old_tbl" statement. –  kinkajou Oct 18 '13 at 4:08
    
The 2 statements in your question do not throw any error. You say - in the comments - that you used select * into new_tbl from old_tbl but I don't see that code in the question. If we can't reproduce the error, how can anyone help? –  ypercube Oct 18 '13 at 12:06
    
@ypercube I created the table using select * into to produce the structure but later I am using the same table structure in production as in question. If I run above two code in my development or production environment I will get the same error even after dropping the created table. –  kinkajou Oct 18 '13 at 13:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.