 




<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: SQL Server equivalent of Oracle&#8217;s desc tablename command</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/sql-server-equivalent-of-oracles-desc-tablename-command/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-server-equivalent-of-oracles-desc-tablename-command/</link>
	<description></description>
	<lastBuildDate>Mon, 20 May 2013 12:39:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: sumeshs</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-server-equivalent-of-oracles-desc-tablename-command/#comment-49311</link>
		<dc:creator>sumeshs</dc:creator>
		<pubDate>Thu, 17 Mar 2005 13:55:41 +0000</pubDate>
		<guid isPermaLink="false">#comment-49311</guid>
		<description><![CDATA[Use this script, create it it in the database you need and grant exec to public.

ALTER    procedure Descr(@pi_table varchar(30), @pi_schema Varchar(30)= &#039;dbo&#039;)
AS
BEGIn
DECLARE
@l_table 	Char(30),
@l_col		Char(30),
@l_typ		VarChar(30),
@l_colH		Char(30),
@l_typH		Char(20),
@l_prec		int,
@l_scale	int,
@l_len		int,
@l_null 	CHAR(10),
@l_nullH 	CHAR(10),
@l_msg		Varchar(1000),
@l_first 	int,
@c1  CURSOR
--Start

IF (@pi_schema is NULL)
    set @pi_schema = &#039;dbo&#039;

set @l_colH = &#039;Column Name&#039;
set @l_nullH = &#039;NULL?&#039;
set @l_typH = &#039;Data Type&#039;

set @c1 = Cursor
For
  select obj.name,
	 col.name,
	 upper(typ.name),
	 ISNULL(col.xprec, 0),
	 ISNULL(col.scale,0),
         col.length,
         case col.isnullable when 1 then &#039;NULL&#039; else &#039;NOT NULL&#039; end
  FROM	sysobjects obj,
 	syscolumns col, 
	systypes typ 
  where  obj.id = col.id
  AND    obj.xtype in (&#039;U&#039;, &#039;V&#039;)
  AND    col.xusertype = typ.xusertype
  and    obj.name  = @pi_Table
  and    user_name(obj.uid) = @pi_schema

  OPen @C1
  fetch next from @c1
        into @l_table,@l_col,@l_typ,@l_prec,@l_scale,@l_len,@l_null
  IF (@@fetch_status 0 )
  BEGIN
    set @l_msg = &#039;Object Not found in the Schema &#039;+ @pi_schema + &#039; of The Database &#039; + db_NAme()
    Print @l_msg
  END
  set @l_first = 1
  While (@@fetch_status = 0)
  BEGIN
    IF  @l_first = 1 
    BEGIN
      set @l_msg = &#039;TSQL &gt; &#039; + &#039;DESC &#039; + @l_table
      print @l_msg
      --set @l_msg = &#039;--------------------    -------------   -------------&#039;
      --print @l_msg
      set @l_msg = @l_colH + @l_nullH + @l_typH
      print @l_msg
      set @l_msg = &#039;--------------------          --------  -----------&#039;
      print @l_msg
    END
    --print @l_typ
    If (@l_typ = &#039;CHAR&#039;) or (@l_typ = &#039;VARCHAR&#039;) 
      set @l_typ = @l_typ + &#039;(&#039; + cast(@l_len as varchar) + &#039;)&#039;
    If (@l_typ = &#039;NUMERIC&#039;) or (@l_typ = &#039;DECIMAL&#039;) 
      set @l_typ = @l_typ + &#039;(&#039; + cast(@l_prec as varchar)+ &#039;,&#039;+ cast(@l_scale as varchar)+ &#039;)&#039;

    set @l_msg = @l_col + @l_null + @l_typ
    print @l_msg
    set @l_first = 2
    fetch next from @c1
        into @l_table,@l_col,@l_typ,@l_prec,@l_scale,@l_len,@l_null
   END 
   close @c1
   deallocate @c1
END




GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

The syntax is &quot;descr &#039;tablename&#039;&quot;

Have fun,
Sumesh]]></description>
		<content:encoded><![CDATA[<p>Use this script, create it it in the database you need and grant exec to public.</p>
<p>ALTER    procedure Descr(@pi_table varchar(30), @pi_schema Varchar(30)= &#8216;dbo&#8217;)<br />
AS<br />
BEGIn<br />
DECLARE<br />
@l_table 	Char(30),<br />
@l_col		Char(30),<br />
@l_typ		VarChar(30),<br />
@l_colH		Char(30),<br />
@l_typH		Char(20),<br />
@l_prec		int,<br />
@l_scale	int,<br />
@l_len		int,<br />
@l_null 	CHAR(10),<br />
@l_nullH 	CHAR(10),<br />
@l_msg		Varchar(1000),<br />
@l_first 	int,<br />
@c1  CURSOR<br />
&#8211;Start</p>
<p>IF (@pi_schema is NULL)<br />
    set @pi_schema = &#8216;dbo&#8217;</p>
<p>set @l_colH = &#8216;Column Name&#8217;<br />
set @l_nullH = &#8216;NULL?&#8217;<br />
set @l_typH = &#8216;Data Type&#8217;</p>
<p>set @c1 = Cursor<br />
For<br />
  select obj.name,<br />
	 col.name,<br />
	 upper(typ.name),<br />
	 ISNULL(col.xprec, 0),<br />
	 ISNULL(col.scale,0),<br />
         col.length,<br />
         case col.isnullable when 1 then &#8216;NULL&#8217; else &#8216;NOT NULL&#8217; end<br />
  FROM	sysobjects obj,<br />
 	syscolumns col,<br />
	systypes typ<br />
  where  obj.id = col.id<br />
  AND    obj.xtype in (&#8216;U&#8217;, &#8216;V&#8217;)<br />
  AND    col.xusertype = typ.xusertype<br />
  and    obj.name  = @pi_Table<br />
  and    user_name(obj.uid) = @pi_schema</p>
<p>  OPen @C1<br />
  fetch next from @c1<br />
        into @l_table,@l_col,@l_typ,@l_prec,@l_scale,@l_len,@l_null<br />
  IF (@@fetch_status 0 )<br />
  BEGIN<br />
    set @l_msg = &#8216;Object Not found in the Schema &#8216;+ @pi_schema + &#8216; of The Database &#8216; + db_NAme()<br />
    Print @l_msg<br />
  END<br />
  set @l_first = 1<br />
  While (@@fetch_status = 0)<br />
  BEGIN<br />
    IF  @l_first = 1<br />
    BEGIN<br />
      set @l_msg = &#8216;TSQL &gt; &#8216; + &#8216;DESC &#8216; + @l_table<br />
      print @l_msg<br />
      &#8211;set @l_msg = &#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;    &#8212;&#8212;&#8212;&#8212;-   &#8212;&#8212;&#8212;&#8212;-&#8217;<br />
      &#8211;print @l_msg<br />
      set @l_msg = @l_colH + @l_nullH + @l_typH<br />
      print @l_msg<br />
      set @l_msg = &#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;          &#8212;&#8212;&#8211;  &#8212;&#8212;&#8212;&#8211;&#8217;<br />
      print @l_msg<br />
    END<br />
    &#8211;print @l_typ<br />
    If (@l_typ = &#8216;CHAR&#8217;) or (@l_typ = &#8216;VARCHAR&#8217;)<br />
      set @l_typ = @l_typ + &#8216;(&#8216; + cast(@l_len as varchar) + &#8216;)&#8217;<br />
    If (@l_typ = &#8216;NUMERIC&#8217;) or (@l_typ = &#8216;DECIMAL&#8217;)<br />
      set @l_typ = @l_typ + &#8216;(&#8216; + cast(@l_prec as varchar)+ &#8216;,&#8217;+ cast(@l_scale as varchar)+ &#8216;)&#8217;</p>
<p>    set @l_msg = @l_col + @l_null + @l_typ<br />
    print @l_msg<br />
    set @l_first = 2<br />
    fetch next from @c1<br />
        into @l_table,@l_col,@l_typ,@l_prec,@l_scale,@l_len,@l_null<br />
   END<br />
   close @c1<br />
   deallocate @c1<br />
END</p>
<p>GO<br />
SET QUOTED_IDENTIFIER OFF<br />
GO<br />
SET ANSI_NULLS ON<br />
GO</p>
<p>The syntax is &#8220;descr &#8216;tablename&#8217;&#8221;</p>
<p>Have fun,<br />
Sumesh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: benjit</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-server-equivalent-of-oracles-desc-tablename-command/#comment-49312</link>
		<dc:creator>benjit</dc:creator>
		<pubDate>Tue, 15 Mar 2005 14:46:30 +0000</pubDate>
		<guid isPermaLink="false">#comment-49312</guid>
		<description><![CDATA[For any object in SQL Server you can use the system stored procedure sp_help.

If you simply type SP_HELP in a query window you will get a list of all db objects including views, table, stored procedures, etc.

If you type sp_help SomeTableName it will provide a lot of information regarding that table. Table columns, datatype, nullability, etc. It also shows constraints on your table, etc. It tells you if you have an Identity column defined and the parameters for the Identity column. There are number of other things it provides...great tool.

sp_index SomeTableName will provide detail index list and the index properties.

If you are doing database work much in SQL server it will save you a lot of time to read through Books Online or TSQL Help on the stored procedures starting with SP_ and XP_. There are lot that you can skip for scheduling and replication if you are not using those featuers. But, the others will provide a lot of information.

Cheers]]></description>
		<content:encoded><![CDATA[<p>For any object in SQL Server you can use the system stored procedure sp_help.</p>
<p>If you simply type SP_HELP in a query window you will get a list of all db objects including views, table, stored procedures, etc.</p>
<p>If you type sp_help SomeTableName it will provide a lot of information regarding that table. Table columns, datatype, nullability, etc. It also shows constraints on your table, etc. It tells you if you have an Identity column defined and the parameters for the Identity column. There are number of other things it provides&#8230;great tool.</p>
<p>sp_index SomeTableName will provide detail index list and the index properties.</p>
<p>If you are doing database work much in SQL server it will save you a lot of time to read through Books Online or TSQL Help on the stored procedures starting with SP_ and XP_. There are lot that you can skip for scheduling and replication if you are not using those featuers. But, the others will provide a lot of information.</p>
<p>Cheers</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 6/8 queries in 0.008 seconds using memcached
Object Caching 283/284 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-20 13:26:25 -->