Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6677175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:05:05+00:00 2026-05-26T04:05:05+00:00

I have written a stored procedure in SQL Server 2000. I want a serial

  • 0

I have written a stored procedure in SQL Server 2000. I want a serial number for output table.
So when I run this stored proc I get this error:

An explicit value for the identity column in table
‘#tmpSearchResults1’ can only be specified when a column list is used
and IDENTITY_INSERT is ON.

I have tried with set IDENTITY_INSERT #tmpSearchResults1 on

Create Procedure dbo.usp_mobile_All_KeyWord(@searchkey varchar(30))                                        
AS          
CREATE TABLE #tmpSearchResults        
(                                                 
 property_id varchar(255),                                                          
 property_number varchar(255),                                                          
 auction_date_reason  varchar(255)                                        
) 

INSERT INTO #tmpSearchResults         

SELECT              

 p.property_id, p.property_number, p.auction_date_reason                                                             
   FROM                                                              
 Pr p               
 INNER JOIN                                                              
 Au a ON p.auction_id = a.auction_id                                                                
 INNER JOIN                                         
 PrAdd pa ON p.property_id = pa.property_id                                        

 INNER JOIN state AS s ON s.state_id=pa.state                
 where            
   (        
   (p.archive = 'N'               

 AND                                                     
 a.show_on_site = 'Y'                                                              
 AND                                                              
 (        
 (        
 ((p.auction_date >= CONVERT(datetime, CONVERT(varchar, GETDATE(), 103), 103) and  (p.auction_date_reason is null or p.auction_date_reason = ''))        
 or         
 (p.auction_date <= CONVERT(datetime, CONVERT(varchar, GETDATE(), 103), 103) and  ( p.auction_date_reason = 'Accepting Offers' )))        
 and        

 pa.property_address_type_id = 1 )) )        
  and         
  (state_abbreviation=@searchkey or  s.state_name like '%'+''+ @searchkey +''+'%' or city  like '%'+''+ @searchkey +''+'%' or  pa.address1 like '%'+''+ @searchkey +''+'%'        
          or  pa.address2 like '%'+''+ @searchkey +''+'%')         
 )      

)         


 CREATE TABLE #tmpSearchResults1        
(            
i1 int identity,                                          
 property_id varchar(255),                                                          
 property_number varchar(255),                                                          
 auction_date_reason  varchar(255)    
)        
 insert into #tmpSearchResults1      

 select     
property_id ,                                                          
 property_number,                                                          
 auction_date_reason                                            

 from #tmpSearchResults       

 order by        
 case when charindex(@searchkey,state) >0 then 1000 else 0 end desc,        
  case when charindex(@searchkey,statename) >0 then 1000 else 0 end desc,        
 case when charindex(@searchkey,city) >0 then 1000 else 0 end desc,         
 case when charindex(@searchkey,address2) >0 then 1000 else 0 end desc,        
 case when charindex(@searchkey,address1) >0 then 1000 else 0 end desc,        
 case when charindex(@searchkey,short_description) >0 then 1000 else 0 end desc      

 select * from #tmpSearchResults1     

Plz do help me

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:05:06+00:00Added an answer on May 26, 2026 at 4:05 am

    The error code is very very very clear.

    The relevant portion is ...when a column list is used....

    You need to specify your column list in the INSERT statement.

    INSERT INTO #tmpSearchResults
    (i1, 
     property_id,                                                          
     property_number,                                                          
     auction_date_reason)         
    
    SELECT              
    
     p.property_id, p.property_number, p.auction_date_reason                                                             
       FROM... 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure written in T-SQL and want to use a table
Hai Techies, I have some stored procedure which was written in SQL server.Now i
I'm writing a stored procedure on SQL Server 2000. I've written a complicated select
Scenario I have a stored procedure written in T-Sql using SQL Server 2005. SEL_ValuesByAssetName
I am creating a stored procedure in SQL Server via SSMS. I have written
I have a number of manually written scripts (.sql) for tables, views and stored
I have a boolean variable value stored in an SQL Server database. This is
I want to backup a SQL Server database with C#. I have written a
I've written a paged search stored procedure using SQL Server 2005. It takes a
Reference: SQL Server I have a stored procedure with a while loop in it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.