My current CRF is to add 134 entries in a table. Initially, I have thought my query to be like this one:
Use Database
Insert INTO Table (Col1, Col2)
VALUES ('Hello','World');
Insert INTO Table (Col1, Col2)
VALUES ('Hello','Philippines');
Insert INTO Table (Col1, Col2)
VALUES ('Hello','Quezon City');
Insert INTO Table (Col1, Col2)
VALUES ('Hello','Gilmore');
Insert INTO Table (Col1, Col2)
VALUES ('Hello','Sykes');
kahit copy-paste lang ang gagawin ko, ang fanet na paulit-ulit si INSERT. So... I asked for google's help for this. Gusto ko na isang INSERT lang ang gagamitin ko. Fortunately, pwede ngang ISA LANG! hahaha. An alternative to repeated INSERT is the use of INSERT INTO...SELECT...UNION ALL statement.
Use Database
INSERT INTO Table (Col1, Col2)
SELECT 'Hello','World'
UNION ALL
SELECT 'Hello','Philippines'
UNION ALL
SELECT 'Hello','Quezon City'
UNION ALL
SELECT 'Hello','Gilmore'
UNION ALL
SELECT 'Hello','Sykes'
UNION ALL
hehe. kahit copy-paste sia, kung sa performance basis, the alternative way is much more efficient. the difference can be seen pag mas malaking entries ang ilalagay sa table. ayus! new learning for today. :D
Thanks to http://blog.sqlauthority.com/2007/06/08/sql-server-insert-multiple-records-using-one-insert-statement-use-of-union-all/ for this helpful article. ^__^
---
WOOOT PROGRAMMER KUNO ANG POST KO! hahaha. JUST SHARING SOMETHING VALUABLE. :D
私は内側からの叫び
Ii otoko da. Kono tamago no atama no hito
私のプロフィール
:makre.
:21.
:filipino.
:thomasian.
:theresian.
:computer science grad.
:associate software engineer.
:.net developer.
:gemini.
:rabbit.
:green & red color lover.
:astronomy addict.
:uses badminton as a stress reliever.
:likes math and music.
:likes the movie castaway.
:yuyu hakusho addict.
:kurama, zhou yu min, son ye jin, and tom hanks fan.
:loves fireworks and ferris wheels.
:trying-hard guitar & keyboard player.
:inclined with the japanese language.
:addicted to breads.
:spitz music lover.<3
:21.
:filipino.
:thomasian.
:theresian.
:computer science grad.
:associate software engineer.
:.net developer.
:gemini.
:rabbit.
:green & red color lover.
:astronomy addict.
:uses badminton as a stress reliever.
:likes math and music.
:likes the movie castaway.
:yuyu hakusho addict.
:kurama, zhou yu min, son ye jin, and tom hanks fan.
:loves fireworks and ferris wheels.
:trying-hard guitar & keyboard player.
:inclined with the japanese language.
:addicted to breads.
:spitz music lover.<3
話そう
ラベル
- animation (22)
- Drama (1)
- Literature (8)
- Movies (8)
- Music (27)
- Out of the Box (19)
- Personal (253)
- Showbiz (58)
- Social (3)
- Technical (10)
最近の記事
リンク
カウンター
火曜日, 10月 02, 2007
SQL SERVER MODE: Inserting Multiple Records Using One Insert Statement - Use of UNION ALL
叫んだ -> M A K R ELabels: Technical
登録:
コメントの投稿 (Atom)


2 comments:
wow! ok 'to ah. may ganyan din ako karaming updates dati. pinagtyagahan kong isa-isahin huhu.
now i know may mas madaling way pala hehe. matsala!
may isshare na ko sa new learning! hehehehe. :D
コメントを投稿