June 15, 2005 at 7:05 am
Hello friends,
As in Oracle Database we can check the structure of table by
DESC <Table_Name>
But Can we check the same in Sql Server2000?
Thanks In Advance
Shashank
Regards,
Papillon
June 15, 2005 at 7:13 am
sp_help <tableName>
🙂
June 15, 2005 at 7:17 am
sp_help is pretty comprehensive...
You can also query the system tables with something like:
select * from syscolumns where id =
(select id from sysobjects where name = )
**ASCII stupid question, get a stupid ANSI !!!**
June 15, 2005 at 7:24 am
that should read...
select * from syscolumns where id =
(select id from sysobjects where name = 'tablename')
**ASCII stupid question, get a stupid ANSI !!!**
June 15, 2005 at 8:10 am
Try this......this may also help as a base metadata view for generating other code.
SELECT
so.[name] AS 'TableName',
sc.[name] AS 'ColumnName',
st.[name] AS 'ColumnType',
sc.length AS 'ColumnSize',
CASE sc.isnullable
WHEN 0 THEN 'No' ELSE 'Yes' END AS 'IsNullable',
myTemp.RefColumn,
myTemp.RefTable
FROM
sysobjects so
INNER JOIN syscolumns sc ON
so.[id] = sc.[id]
INNER JOIN
systypes st ON
sc.xtype = st.xtype
LEFT OUTER JOIN(
SELECT
sfk.constid AS 'ConstraintID',
sfk.fkeyid AS 'TableID',
sfk.fkey AS 'ColumnID',
sc.[name] AS 'RefColumn',
so.[name] AS 'RefTable',
sfk.rkeyid AS 'TableID Ref',
sfk.rkey AS 'ColumnID Ref'
FROM
sysforeignkeys sfk
INNER JOIN syscolumns sc ON
sfk.rkeyid = sc.[id]
AND
sfk.rkey = sc.colid
INNER JOIN sysobjects so ON
sc.[id] = so.[id]
  myTemp ON
myTemp.TableID = sc.[id]
AND
myTemp.ColumnID = sc.colid
WHERE
so.type = 'U'
AND
so.[name] NOT LIKE 'dt%'
--SELECT * FROM syscolumns
--SELECT * FROM systypes
June 15, 2005 at 8:54 am
You can also run the following:
select * from information_schema.columns
which will return all column information for each table in the current database
June 15, 2005 at 5:36 pm
As long as you're using QA, why not just use the Object Browser and save some typing?
Greg
Greg
June 15, 2005 at 7:02 pm
Drag 'N' Drop is your friend.
If only it did the quoting properly when you drag the columns in
--------------------
Colt 45 - the original point and click interface
June 16, 2005 at 12:15 am
Hello friends,
Thanks for that!!!!!!!!!!!!!!!!!!!!!!
shashank
Regards,
Papillon
June 16, 2005 at 11:55 am
sp_columns tablename
June 16, 2005 at 12:10 pm
Many ways to skin this cat - <;-) - though object browser is the way to go for a quick dekko!!!
**ASCII stupid question, get a stupid ANSI !!!**
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply