Hi all,
Sql server 7
i have two databases best and books.Most of the tables present in best are in books except some.
i have been given a task to list out the tables and columns of which are present in best database and not in books database.
Pls suggest me the simplest and quickest way to do this.
this is very urgent.
waiting for reply.
TIA
AdilI'd just run selects from sysobjects and syscolumns, which are SQL Server's method of storing object definitions. Others on this forum will probably suggest selecting from the SCHEMA tables.|||Check LEFT OUTER JOIN in BOL, this should be very trivial (hint: ...no, t's too trivial ;) )|||hi
thnks for reply
can u tell me as to how i can select columns of a particular table using syscolumns
thansks once again|||Originally posted by aadil
hi
thnks for reply
can u tell me as to how i can select columns of a particular table using syscolumns
thansks once again
You could use linked servers. Query below will return list of tables from server1 if these are no the same column(s) on server2. Checking for object owner also is included.
select 'User table ['+su.name+'.'+so.name+'] does not have column ['+sc.name+']'
from server1.dbo.sysobjects so
join server1.dbo.syscolumns sc on sc.id=so.id
join server1.dbo.sysusers su on su.uid=so.uid
where so.xtype='U'
and exists(select 'ok' from server2.dbo.sysobjects r
join server2.dbo.sysusers sur on sur.uid=r.uid and sur.name=su.name
where xtype='U' and r.name=so.name)
and not exists(select 'ok' from server2.dbo.sysobjects sor
join server2.dbo.sysusers sul on sul.uid=sor.uid and sul.name=su.name
join server2.dbo.syscolumns scr on scr.id=sor.id
where sor.xtype='U' and sor.name=so.name and scr.name=sc.name)'
Showing posts with label books. Show all posts
Showing posts with label books. Show all posts
Thursday, March 29, 2012
Friday, February 10, 2012
Comma operator in FROM clause - what is this?
I know how it functions, but what does this mean exactly, and where can
I find it in the books online?
SELECT *
FROM Table1, Table2
What is the name of that Comma's function?
Thanks,
JeremyMost often, this is what we consider an old style join, which you forgot to
restrict. Old style
join, as in
SELECT ...
FROM titles AS t, publishers AS p
WHERE t.pub_id = p.pub_id
Above is the same query as:
SELECT ...
FROM titles AS t
JOIN publishers AS p ON t.pub_id = p.pub_id
No, if you remove the WHERE clause from the first query, you get all rows fr
om titles, combined with
all rows from publihers. In most cases, a meaningless result. We call this c
artesian product, cross
join or unrestricted join. You can accomplish this using the new join syntax
as:
SELECT ...
FROM titles AS t CROSS JOIN publishers AS p
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Jeremy Cowles" <jeremy.cowles@.gmail.com> wrote in message
news:1134662287.068773.293050@.g49g2000cwa.googlegroups.com...
>I know how it functions, but what does this mean exactly, and where can
> I find it in the books online?
> SELECT *
> FROM Table1, Table2
>
> What is the name of that Comma's function?
> Thanks,
> Jeremy
>|||The comma is simply a delimiter. In your from clause you can list all the
tables/views/in line views you are accessing, seperated by commas, then
define your join criteria in the where clause. If you have no join criteria
then the result is a cartesion product (every row in table 1 is joined with
every row in table 2).
"Jeremy Cowles" <jeremy.cowles@.gmail.com> wrote in message
news:1134662287.068773.293050@.g49g2000cwa.googlegroups.com...
> I know how it functions, but what does this mean exactly, and where can
> I find it in the books online?
> SELECT *
> FROM Table1, Table2
>
> What is the name of that Comma's function?
> Thanks,
> Jeremy
>|||Spanx!
I find it in the books online?
SELECT *
FROM Table1, Table2
What is the name of that Comma's function?
Thanks,
JeremyMost often, this is what we consider an old style join, which you forgot to
restrict. Old style
join, as in
SELECT ...
FROM titles AS t, publishers AS p
WHERE t.pub_id = p.pub_id
Above is the same query as:
SELECT ...
FROM titles AS t
JOIN publishers AS p ON t.pub_id = p.pub_id
No, if you remove the WHERE clause from the first query, you get all rows fr
om titles, combined with
all rows from publihers. In most cases, a meaningless result. We call this c
artesian product, cross
join or unrestricted join. You can accomplish this using the new join syntax
as:
SELECT ...
FROM titles AS t CROSS JOIN publishers AS p
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Jeremy Cowles" <jeremy.cowles@.gmail.com> wrote in message
news:1134662287.068773.293050@.g49g2000cwa.googlegroups.com...
>I know how it functions, but what does this mean exactly, and where can
> I find it in the books online?
> SELECT *
> FROM Table1, Table2
>
> What is the name of that Comma's function?
> Thanks,
> Jeremy
>|||The comma is simply a delimiter. In your from clause you can list all the
tables/views/in line views you are accessing, seperated by commas, then
define your join criteria in the where clause. If you have no join criteria
then the result is a cartesion product (every row in table 1 is joined with
every row in table 2).
"Jeremy Cowles" <jeremy.cowles@.gmail.com> wrote in message
news:1134662287.068773.293050@.g49g2000cwa.googlegroups.com...
> I know how it functions, but what does this mean exactly, and where can
> I find it in the books online?
> SELECT *
> FROM Table1, Table2
>
> What is the name of that Comma's function?
> Thanks,
> Jeremy
>|||Spanx!
Subscribe to:
Posts (Atom)