显示标签为“description”的博文。显示所有博文
显示标签为“description”的博文。显示所有博文

2012年3月11日星期日

Any T-SQL command can show the description of specified table columns?

I want to ask something because i need.

Any SQL/T-SQL command inside MsSQL Server 2000 can show the description of {all table columns or specified table columns} of specified table inside specified database?

can you teach me how to do and any example(s)?Try checking out the INFORMATION_SCHEMA.COLUMNS view:


SELECT
*
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
TABLE_CATALOG = 'myDatabase' AND
TABLE_NAME = 'myTable'

Terri|||You can also use the following:

exec sp_columns 'table_name'

This will return the list of columns for the table you specified.

2012年2月11日星期六

ANSI-92 inner join vs. where clause syntax

Having problems rewriting my join condition using the "inner join" syntax.

My query, working with an intersection table:

SELECT Description, EmailAddress
FROM Accounts_Roles r, Accounts_Users u, Accounts_UserRoles ur
WHERE
r.RoleID = ur.RoleID
AND
u.UserID = ur.UserID

This works fine, but i want to write it using 'inner join' style, so I tried:

SELECT Description, EmailAddress
FROM Accounts_Roles r, Accounts_Users u
INNER JOIN Accounts_UserRoles ur
ON
r.RoleID = ur.RoleID
AND
u.UserID = ur.UserID

which gives me an error (The column prefix 'r' does not match with a table name or alias name used in the query.)

Any ideas as to how I'm screwing this up would be appreciated.

Thanks,
Gordon ZI'd use:SELECT Description, EmailAddress
FROM Accounts_UserRoles ur
INNER JOIN Accounts_Roles r
ON (r.RoleID = ur.RoleID)
INNER JOIN Accounts_Users u
ON (u.UserID = ur.UserID)-PatP|||Someone here (at Rackspace) has already come up with a cleche based on talking to me: Take the JOIN out of your WHERE clause (and then adding something like "...and take your head out of your @.$$"), which is actually based on what Rudy (come out and play here!!!) would enumerate for you very accurately, but I just say that WHERE is processed after JOIN. So I'll let you come up to your own conclusion ;)|||i really admire people who recognize that there is a difference between JOIN syntax and the older table list method, and are trying to make the change and learn the better way