How to insert multiple rows of data in SQL Server 2008 R2

Source: Internet
Author: User

When you insert multiple rows of data, you do not have to write more than n insert INTO.

SELECT DISTINCT ' (' + ' "' +loginip + ' + ') ' + ', ' from dbo. Login

WHERE LoginName in

(

SELECT DISTINCT loginname from dbo. Login

WHERE loginip= ' 61.170.245.61 '

)

Go

--to obtain such a result

(' 61.61.245.243 '),

(' 61.61.245.61 '),

So direct

INSERT INTO Testip values

(' 1.192.47.125 '),

(' 1.58.113.154 '),

(' 1.85.189.111 '),

(' 1.86.37.156 '),

(' 101.84.100.87 '),

(' 106.83.49.191 ') high efficiency!

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/SQLServer/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.