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 8352841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:05:17+00:00 2026-06-09T09:05:17+00:00

I have came up with this query, does not produce any error while praise,

  • 0

I have came up with this query, does not produce any error while praise, but I Don’t know if I can use this select statement as the value

insert into store(c1 ,artno, c3, c4, c5, c6, c7 )
           select '1', a.artno, 0,0.0,null,null,null 
           from art a
              left join store s on s.artno=a.artno
              inner join status b on a.artno = b.artno
    where b.state ='5'  
      and s.artno is null  
      and a.artgroup not in('63','280') 

I also saw another alternative which may be used but not sure if it can be used to insert as my requirement, I saw this implemented in stored procedure so just grabbed the idea if it can be used?

declare @artno as varchar(150); 
declare @count as tinyint

Declare cS CURSOR For
               select  a.artno
               from art a
              left join store s on s.artno=a.artno
              inner join status b on a.artno = b.artno
    where b.staus ='5'  
      and s.artno is null  
      and a.artgroup not in('63','280') 


Open cS
Fetch NEXT from cS into @artno

While @@FETCH_STATUS=0

select @count=COUNT(*) from store where artno=@artno
if @count=0 

 BEGIN

insert into store(c1 ,artno, c3, c4, c5, c6, c7 )
           values('1', a.artno, 0,0.0,null,null,null)                 

    fetch next from cS into @artno                 
 END 
 close cS
 deallocate cS

Some explanation which to use and which not to and why, would help me for my knowledge as well.

  • 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-06-09T09:05:19+00:00Added an answer on June 9, 2026 at 9:05 am

    Cursors are memory intensive and time consuming. Whereas SELECT INTO would have pre-constructed the table content to be inserted and can do it in a single stretch. Also in case of SELECT INTO, SQL Engine has chance of optimizing the data fetch whereas in case of cursor, you are forcing the DB to fetch rows sequentially and no optimization is possible.

    http://blog.sqlauthority.com/2011/08/10/sql-server-use-insert-into-select-instead-of-cursor/

    Go through the above link which advocates my statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data, yes, data. This data came from a MySQL query and
While doing some small regex task I came upon this problem. I have a
I have been using Perl for some time, but today I came across this
While setting up Sphinx on my production server, this strange error came up when
I have scoured the net for this question and have came up empty handed.
Today I came across this question: you have a code static int counter =
I came across this code on reddit . I would have thought that type
I was doing a bit research and I came across this comment. I have
I have been on this mysql query for 2 days running. This is the
This question came into my mind while generating sample data for a SO-answer. I

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.