One of the superb feature of sql server is application of cross joins.
It provides an option of multiple select statement into a single insert statement. I've happened to work in sql server for getting lot of informations from different select statement and I need to insert into a single insert statement.. In this case, my cross join helps me a lot.
Here is the syntax for the same.
SELECT
f1.col1, f2.col2, f3.col3, f4.col4
FROM
(select count(1) AS col1
from SystemBasedUser() where ID like '%MS_SQL%') AS F1
CROSS JOIN
(select count(1) AS col2
from SystemBasedUser() where ID like '%MS_POLI%') AS F2
CROSS JOIN
(select count(1) AS col3
from SystemBasedUser() where ID like '%MS_SMO%') AS F3
CROSS JOIN
(select count(1) AS col4
from SystemBasedUser() where ID like '%MS_AGEN%') AS F4
f1.col1, f2.col2, f3.col3, f4.col4
FROM
(select count(1) AS col1
from SystemBasedUser() where ID like '%MS_SQL%') AS F1
CROSS JOIN
(select count(1) AS col2
from SystemBasedUser() where ID like '%MS_POLI%') AS F2
CROSS JOIN
(select count(1) AS col3
from SystemBasedUser() where ID like '%MS_SMO%') AS F3
CROSS JOIN
(select count(1) AS col4
from SystemBasedUser() where ID like '%MS_AGEN%') AS F4
Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
No comments:
Post a Comment