﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Discuss Content Posted by Yakov Shlafman / Article Discussions / Article Discussions by Author  / Query Analyzer Extended / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 19 Jun 2013 17:22:11 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Query Analyzer Extended</title><link>http://www.sqlservercentral.com/Forums/Topic214522-247-1.aspx</link><description>&lt;P&gt;May be just give a try.&lt;/P&gt;&lt;P&gt;USE NorthWindGO&lt;/P&gt;&lt;P&gt;DECLARE @tblName VARCHAR(35)SELECT @tblName = 'Products'&lt;/P&gt;&lt;P&gt;SELECT  [DeclareStmt] = RTRIM('DECLARE @'+C.[Name]+SPACE(CharLen-LEN(C.[Name]))+CHAR(9)        +CASE   WHEN T.[Name] IN        ('SMALLDATETIME','DATATIME','TEXT','IMAGE','BIT','NTEXT','UNIQUEIDENTIFIER',                                        'BIGINT','INT','SMALLINT','TINYINT','MONEY','SMALLMONEY')                        THEN    UPPER(T.[Name])                WHEN T.[Name] IN ('DECIMAL','NUMERIC')                        THEN    UPPER(T.[Name]) + + '(' + CAST(C.[Length] AS VARCHAR(255)) + ') [' + CAST(C.[XPrec] AS VARCHAR(255))                                + ',' + CAST(C.[XScale] AS VARCHAR(255)) + ']'                ELSE    UPPER(T.[Name]) + '(' + CAST(C.[Length] AS VARCHAR(255)) + ')'        END),        [InsertStmt]    = RTRIM(QUOTENAME(C.[Name],'[]')+CASE WHEN C.ColId &amp;lt;&amp;gt; MaxLen.CId THEN ',' ELSE '' END),        [ValuesStmt]    = RTRIM(&lt;A href="mailto:'@'+C.[Name]+CASE"&gt;'@'+C.[Name]+CASE&lt;/A&gt; WHEN C.ColId &amp;lt;&amp;gt; MaxLen.CId THEN ',' ELSE '' END),        [UpdateStmt]    = RTRIM(QUOTENAME(C.[Name],'[]')+SPACE(CharLen-LEN(C.[Name]))+CHAR(9)+' = @'+C.[Name]                        +CASE WHEN C.ColId &amp;lt;&amp;gt; MaxLen.CId THEN ',' ELSE '' END),        [AssignStmt]    = RTRIM(&lt;A href="mailto:'@'+C.[Name]+SPACE(CharLen-LEN(C.[Name]))+CHAR(9)+'"&gt;'@'+C.[Name]+SPACE(CharLen-LEN(C.[Name]))+CHAR(9)+'&lt;/A&gt; = '+QUOTENAME(C.[Name],'[]')+                          CASE WHEN C.ColId &amp;lt;&amp;gt; MaxLen.CId THEN ',' ELSE '' END),        [DefaultValue]  = SC.[Text], [ConstName] = Obj.[Name], Nullable = CASE WHEN C.[IsNullable] = 1 THEN 'Y' ELSE 'N' END, IsIdentity = CASE WHEN C.[Status]&amp;amp;0x80 = 0x80 THEN 'Y' ELSE 'N' END, [ProcParams] = RTRIM(&lt;A href="mailto:'@'+C.[Name]+SPACE(CharLen-LEN(C.[Name]))+CHAR(9"&gt;'@'+C.[Name]+SPACE(CharLen-LEN(C.[Name]))+CHAR(9&lt;/A&gt;)        +CASE   WHEN T.[Name] IN        ('SMALLDATETIME','DATATIME','TEXT','IMAGE','BIT','NTEXT','UNIQUEIDENTIFIER',                                        'BIGINT','INT','SMALLINT','TINYINT','MONEY','SMALLMONEY')                        THEN    UPPER(T.[Name])                WHEN T.[Name] IN ('DECIMAL','NUMERIC')                        THEN    UPPER(T.[Name]) + + '(' + CAST(C.[Length] AS VARCHAR(255)) + ') [' + CAST(C.[XPrec] AS VARCHAR(255))                                + ',' + CAST(C.[XScale] AS VARCHAR(255)) + ']'                ELSE    UPPER(T.[Name]) + '(' + CAST(C.[Length] AS VARCHAR(255))+')'        END)+SPACE((16-LEN(CASE   WHEN T.[Name] IN        ('SMALLDATETIME','DATATIME','TEXT','IMAGE','BIT','NTEXT','UNIQUEIDENTIFIER',                                        'BIGINT','INT','SMALLINT','TINYINT','MONEY','SMALLMONEY')                        THEN    UPPER(T.[Name])                WHEN T.[Name] IN ('DECIMAL','NUMERIC')                        THEN    UPPER(T.[Name]) + + '(' + CAST(C.[Length] AS VARCHAR(255)) + ') [' + CAST(C.[XPrec] AS VARCHAR(255))                                + ',' + CAST(C.[XScale] AS VARCHAR(255)) + ']'                ELSE    UPPER(T.[Name]) + '(' + CAST(C.[Length] AS VARCHAR(255)) + ')'  END))+1)+CHAR(9)+CASE WHEN C.[IsNullable] = 1 THEN '= NULL' ELSE '' END+CASE WHEN C.ColId &amp;lt;&amp;gt; MaxLen.CId THEN ',' ELSE '' ENDFROM    dbo.SysObjects AS O        INNER JOIN dbo.SysColumns AS C                ON      O.[Id] = C.[Id]        INNER JOIN dbo.SysTypes AS T                ON      C.[XType] = T.[XType]                AND     T.[XType] = T.[XUserType]        INNER JOIN (SELECT [Id],MAX(LEN([Name]))+1 AS CharLen,MAX(ColId) AS CId FROM dbo.SysColumns GROUP BY [Id]) AS MaxLen                ON MaxLen.[Id] = C.[Id]        LEFT OUTER JOIN dbo.SysComments AS SC  ON  C.[CDefault] = SC.[Id]  AND SC.[ColId] = 1 LEFT JOIN dbo.SysObjects AS Obj  ON SC.[Id] = Obj.[Id] WHERE   O.[Name] = @tblNameAND     O.XType IN ('U','V')ORDER BY O.[Name],C.[ColId],C.[ColOrder]&lt;/P&gt;&lt;P&gt;Ram&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description><pubDate>Fri, 29 Sep 2006 07:37:00 GMT</pubDate><dc:creator>Ram Ram</dc:creator></item><item><title>RE: Query Analyzer Extended</title><link>http://www.sqlservercentral.com/Forums/Topic214522-247-1.aspx</link><description>&lt;P&gt;May be just give a try.&lt;/P&gt;&lt;P&gt;USE NorthWindGO&lt;/P&gt;&lt;P&gt;DECLARE @tblName VARCHAR(35)SELECT @tblName = 'Products'&lt;/P&gt;&lt;P&gt;SELECT  [DeclareStmt] = RTRIM('DECLARE @'+C.[Name]+SPACE(CharLen-LEN(C.[Name]))+CHAR(9)        +CASE   WHEN T.[Name] IN        ('SMALLDATETIME','DATATIME','TEXT','IMAGE','BIT','NTEXT','UNIQUEIDENTIFIER',                                        'BIGINT','INT','SMALLINT','TINYINT','MONEY','SMALLMONEY')                        THEN    UPPER(T.[Name])                WHEN T.[Name] IN ('DECIMAL','NUMERIC')                        THEN    UPPER(T.[Name]) + + '(' + CAST(C.[Length] AS VARCHAR(255)) + ') [' + CAST(C.[XPrec] AS VARCHAR(255))                                + ',' + CAST(C.[XScale] AS VARCHAR(255)) + ']'                ELSE    UPPER(T.[Name]) + '(' + CAST(C.[Length] AS VARCHAR(255)) + ')'        END),        [InsertStmt]    = RTRIM(QUOTENAME(C.[Name],'[]')+CASE WHEN C.ColId &amp;lt;&amp;gt; MaxLen.CId THEN ',' ELSE '' END),        [ValuesStmt]    = RTRIM(&lt;A href="mailto:'@'+C.[Name]+CASE"&gt;'@'+C.[Name]+CASE&lt;/A&gt; WHEN C.ColId &amp;lt;&amp;gt; MaxLen.CId THEN ',' ELSE '' END),        [UpdateStmt]    = RTRIM(QUOTENAME(C.[Name],'[]')+SPACE(CharLen-LEN(C.[Name]))+CHAR(9)+' = @'+C.[Name]                        +CASE WHEN C.ColId &amp;lt;&amp;gt; MaxLen.CId THEN ',' ELSE '' END),        [AssignStmt]    = RTRIM(&lt;A href="mailto:'@'+C.[Name]+SPACE(CharLen-LEN(C.[Name]))+CHAR(9)+'"&gt;'@'+C.[Name]+SPACE(CharLen-LEN(C.[Name]))+CHAR(9)+'&lt;/A&gt; = '+QUOTENAME(C.[Name],'[]')+                          CASE WHEN C.ColId &amp;lt;&amp;gt; MaxLen.CId THEN ',' ELSE '' END),        [DefaultValue]  = SC.[Text], [ConstName] = Obj.[Name], Nullable = CASE WHEN C.[IsNullable] = 1 THEN 'Y' ELSE 'N' END, IsIdentity = CASE WHEN C.[Status]&amp;amp;0x80 = 0x80 THEN 'Y' ELSE 'N' END, [ProcParams] = RTRIM(&lt;A href="mailto:'@'+C.[Name]+SPACE(CharLen-LEN(C.[Name]))+CHAR(9"&gt;'@'+C.[Name]+SPACE(CharLen-LEN(C.[Name]))+CHAR(9&lt;/A&gt;)        +CASE   WHEN T.[Name] IN        ('SMALLDATETIME','DATATIME','TEXT','IMAGE','BIT','NTEXT','UNIQUEIDENTIFIER',                                        'BIGINT','INT','SMALLINT','TINYINT','MONEY','SMALLMONEY')                        THEN    UPPER(T.[Name])                WHEN T.[Name] IN ('DECIMAL','NUMERIC')                        THEN    UPPER(T.[Name]) + + '(' + CAST(C.[Length] AS VARCHAR(255)) + ') [' + CAST(C.[XPrec] AS VARCHAR(255))                                + ',' + CAST(C.[XScale] AS VARCHAR(255)) + ']'                ELSE    UPPER(T.[Name]) + '(' + CAST(C.[Length] AS VARCHAR(255))+')'        END)+SPACE((16-LEN(CASE   WHEN T.[Name] IN        ('SMALLDATETIME','DATATIME','TEXT','IMAGE','BIT','NTEXT','UNIQUEIDENTIFIER',                                        'BIGINT','INT','SMALLINT','TINYINT','MONEY','SMALLMONEY')                        THEN    UPPER(T.[Name])                WHEN T.[Name] IN ('DECIMAL','NUMERIC')                        THEN    UPPER(T.[Name]) + + '(' + CAST(C.[Length] AS VARCHAR(255)) + ') [' + CAST(C.[XPrec] AS VARCHAR(255))                                + ',' + CAST(C.[XScale] AS VARCHAR(255)) + ']'                ELSE    UPPER(T.[Name]) + '(' + CAST(C.[Length] AS VARCHAR(255)) + ')'  END))+1)+CHAR(9)+CASE WHEN C.[IsNullable] = 1 THEN '= NULL' ELSE '' END+CASE WHEN C.ColId &amp;lt;&amp;gt; MaxLen.CId THEN ',' ELSE '' ENDFROM    dbo.SysObjects AS O        INNER JOIN dbo.SysColumns AS C                ON      O.[Id] = C.[Id]        INNER JOIN dbo.SysTypes AS T                ON      C.[XType] = T.[XType]                AND     T.[XType] = T.[XUserType]        INNER JOIN (SELECT [Id],MAX(LEN([Name]))+1 AS CharLen,MAX(ColId) AS CId FROM dbo.SysColumns GROUP BY [Id]) AS MaxLen                ON MaxLen.[Id] = C.[Id]        LEFT OUTER JOIN dbo.SysComments AS SC  ON  C.[CDefault] = SC.[Id]  AND SC.[ColId] = 1 LEFT JOIN dbo.SysObjects AS Obj  ON SC.[Id] = Obj.[Id] WHERE   O.[Name] = @tblNameAND     O.XType IN ('U','V')ORDER BY O.[Name],C.[ColId],C.[ColOrder]&lt;/P&gt;&lt;P&gt;Ram&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description><pubDate>Fri, 29 Sep 2006 07:37:00 GMT</pubDate><dc:creator>Ram Ram</dc:creator></item><item><title>RE: Query Analyzer Extended</title><link>http://www.sqlservercentral.com/Forums/Topic214522-247-1.aspx</link><description>&lt;P&gt;Hi everybody,&lt;/P&gt;&lt;P&gt;I don't like short names for stored procedures, I prefer to know exactly what a sp is going to do just by looking at its name rather than having to open it and read the code. I'm a Java developer and I'm quite used to dealing with long named functions and methods...&lt;/P&gt;&lt;P&gt;By the way, I see no need for a sp to get table columns information, since I can query INFORMATION_SCHEMA.COLUMNS. If I have to generate code for a statement, I do it querying INFORMATION_SCHEMA, but it must be worth the while: I will never do it for a simple select / insert statement, since it is so easy and strightforward to write sql statements that it would take me much longer to remember the sp name rather than writing the statement by myself.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Gianluca Sartori&lt;/P&gt;</description><pubDate>Fri, 29 Sep 2006 01:31:00 GMT</pubDate><dc:creator>EX Gianluca Sartori</dc:creator></item><item><title>RE: Query Analyzer Extended</title><link>http://www.sqlservercentral.com/Forums/Topic214522-247-1.aspx</link><description>&lt;P&gt;Hi Alan,&lt;/P&gt;&lt;P&gt;now the new, inproved version of the proc with &lt;/P&gt;&lt;P&gt;identity property is available from the same link. Format 1, type 1.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Yakov&lt;/P&gt;</description><pubDate>Wed, 02 Nov 2005 20:22:00 GMT</pubDate><dc:creator>Yakov Shlafman</dc:creator></item><item><title>RE: Query Analyzer Extended</title><link>http://www.sqlservercentral.com/Forums/Topic214522-247-1.aspx</link><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 15pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;FONT size=3&gt;Hi Vernon,&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT size=3&gt;&lt;SPAN style="FONT-SIZE: 15pt; COLOR: black; FONT-FAMILY: Arial"&gt;Kalen Delaney wrote an exellent article "&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 15pt; COLOR: black; FONT-FAMILY: Arial"&gt;User-Defined Data Types" &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;A href="http://www.windowsitpro.com/SQLServer/Article/ArticleID/37427/37427.html"&gt;http://www.windowsitpro.com/SQLServer/Article/ArticleID/37427/37427.html&lt;/A&gt;.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;FONT size=3&gt;She provides a stored procedure that shows all user defined datatypes.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;FONT face=Arial size=3&gt;&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;FONT size=3&gt;Please let me know it this answers all your questions.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;FONT face=Arial size=3&gt;&lt;/FONT&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;FONT size=3&gt;Thanks&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;FONT size=3&gt;Regard&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;FONT size=3&gt;Yakov&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;</description><pubDate>Sat, 15 Oct 2005 19:37:00 GMT</pubDate><dc:creator>Yakov Shlafman</dc:creator></item><item><title>RE: Query Analyzer Extended</title><link>http://www.sqlservercentral.com/Forums/Topic214522-247-1.aspx</link><description>&lt;P&gt;Hi Alan,&lt;/P&gt;&lt;P&gt;I will post a new, inproved version of the proc with &lt;/P&gt;&lt;P&gt;identity property.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Yakov&lt;/P&gt;</description><pubDate>Wed, 05 Oct 2005 08:47:00 GMT</pubDate><dc:creator>yakov shlafman-248344</dc:creator></item><item><title>RE: Query Analyzer Extended</title><link>http://www.sqlservercentral.com/Forums/Topic214522-247-1.aspx</link><description>&lt;P&gt;A long time ago I came across an sp called sp_select on the old site. I have since taken that sp and modified it, munged it so that now I have sp_select, sp_insert, sp_insertselect, and sp_declare. Since I rarely need to do deletes and most updates are pretty specific I never really used the helper sp for them. If I get a chance I will upload them. And yes, I too put the comma at the front. My sp_declare will use UDT's if they exist (I hate those things!) as well.&lt;/P&gt;&lt;P&gt;Basically with the above sprocs I could nearly have the database spit out a sproc for doing selects on a table &lt;img src='images/emotions/smile.gif' height='20' width='20' border='0' title='Smile' align='absmiddle'&gt;&lt;/P&gt;&lt;P&gt;Also, it would be very simple to modify the sp_declare I have to show the field is an identity.&lt;/P&gt;</description><pubDate>Thu, 29 Sep 2005 18:59:00 GMT</pubDate><dc:creator>Gary Johnson-259336</dc:creator></item><item><title>RE: Query Analyzer Extended</title><link>http://www.sqlservercentral.com/Forums/Topic214522-247-1.aspx</link><description>Can it be modified to show the user defined data types instead of the actual datatypes?</description><pubDate>Thu, 29 Sep 2005 09:41:00 GMT</pubDate><dc:creator>Vernon Reeve</dc:creator></item><item><title>RE: Query Analyzer Extended</title><link>http://www.sqlservercentral.com/Forums/Topic214522-247-1.aspx</link><description>&lt;P&gt;&lt;EM&gt;but you cannot see if a column has the identity property set and seed and increment values.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I prefer your format, but the very thing you are talking about is something your procedure doesn't do!&lt;/P&gt;</description><pubDate>Thu, 29 Sep 2005 08:17:00 GMT</pubDate><dc:creator>Alan Armstrong</dc:creator></item><item><title>RE: Query Analyzer Extended</title><link>http://www.sqlservercentral.com/Forums/Topic214522-247-1.aspx</link><description>&lt;P&gt;I wrote a procedure that basically does the same thing.  It was not as robust as yours.  We do a lot of stored procedures and triggers on big tables.&lt;/P&gt;&lt;P&gt;And before everyone complains about the use of cursors, it was a quick and dirty work around for a problem.&lt;img src='images/emotions/whistling.gif' height='20' width='20' title='Whistling' align='absmiddle'&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Use masterif exists (select * from dbo.sysobjects where id = object_id(N'sp_ScriptHelper') and OBJECTPROPERTY(id, N'IsProcedure') = 1)drop procedure sp_ScriptHelperGO&lt;/P&gt;&lt;P&gt;SET QUOTED_IDENTIFIER ON GOSET ANSI_NULLS ON GOSET NOCOUNT ONGO&lt;/P&gt;&lt;P&gt;CREATE PROCEDURE sp_ScriptHelper @tblName nvarchar(50)='', @which int = '0',@Prefix nvarchar(5)=''&lt;/P&gt;&lt;P&gt;AS&lt;/P&gt;&lt;P&gt;Declare @FldName as nvarchar(200)Declare @fldtype as nvarchar(30)Declare @fldlgth as int&lt;/P&gt;&lt;P&gt;if @which = 1 or @which = 0Beginprint '/* Standard Declares for table ' + upper(@tblname) + '*/'Declare tblfields cursor for&lt;/P&gt;&lt;P&gt;SELECT COLUMN_NAME, DATA_TYPE,CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.columns where TABLE_NAME = @tblName order by ORDINAL_POSITION OPEN tblfields FETCH NEXT FROM tblfields INTO @fldName, @fldtype, @fldlgth     WHILE (@@fetch_status &amp;lt;&amp;gt; -1)  BEGIN             if @fldtype&amp;lt;&amp;gt; 'timestamp'   BEGIN    if not @fldlgth is null     if not @Prefix is null      Print 'Declare @' + @Prefix  + @fldname + ' as ' + @fldtype + ' (' + cast(@fldlgth as nvarchar(10)) + ')'     else      Print 'Declare @' + @fldname + ' as ' + @fldtype + ' (' + cast(@fldlgth as nvarchar(10)) + ')'    else      if not @Prefix is null      Print 'Declare @' + @Prefix + @fldname + ' as ' + @fldtype      else      Print 'Declare @' + @fldname + ' as ' + @fldtype    END&lt;/P&gt;&lt;P&gt;  FETCH NEXT FROM tblfields INTO @fldName, @fldtype, @fldlgth  END --end loop&lt;/P&gt;&lt;P&gt;CLOSE tblfieldsDEALLOCATE tblfieldsPrint ''Print ''Print ''ENDIf @which = '0' or @which ='2'Beginprint '/* Standard Variable Load from table ' + upper(@tblname) + '*/'Print ''Print ''Print ''Print 'Select 'Declare tblfields cursor for&lt;/P&gt;&lt;P&gt;SELECT COLUMN_NAME, DATA_TYPE,CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.columns where TABLE_NAME = @tblName order by ORDINAL_POSITION OPEN tblfields FETCH NEXT FROM tblfields INTO @fldName, @fldtype, @fldlgth     WHILE (@@fetch_status &amp;lt;&amp;gt; -1)  BEGIN             if @fldtype&amp;lt;&amp;gt; 'timestamp'     if not @Prefix is null      Print &lt;A href="mailto:'@'"&gt;'@'&lt;/A&gt; + @Prefix  + @fldname + ' = ' + @fldname + ','     else      Print &lt;A href="mailto:'@'"&gt;'@'&lt;/A&gt; + @fldname + ' = ' + @fldname + ','        &lt;/P&gt;&lt;P&gt;  FETCH NEXT FROM tblfields INTO @fldName, @fldtype, @fldlgth  END --end loop&lt;/P&gt;&lt;P&gt;CLOSE tblfieldsDEALLOCATE tblfieldsPrint 'FROM ' + upper(@tblname)Print '/* WHERE clause goes here */'Print ''Print ''Print ''End&lt;/P&gt;&lt;P&gt;IF @which ='0' or @which = '3'Beginprint '/* Standard Insert for table ' + upper(@tblname) + '*/'Print ''Print ''Print ''Print 'INSERT INTO ' + Upper(@tblname) + '('Declare tblfields cursor for&lt;/P&gt;&lt;P&gt;SELECT COLUMN_NAME, DATA_TYPE,CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.columns where TABLE_NAME = @tblName order by ORDINAL_POSITION OPEN tblfields FETCH NEXT FROM tblfields INTO @fldName, @fldtype, @fldlgth     WHILE (@@fetch_status &amp;lt;&amp;gt; -1)  BEGIN                if @fldtype&amp;lt;&amp;gt; 'timestamp'       if not @Prefix is null     Print &lt;A href="mailto:'@'"&gt;'@'&lt;/A&gt; + @Prefix + @fldname + ','    else     Print &lt;A href="mailto:'@'"&gt;'@'&lt;/A&gt; + @fldname + ','   else    Print 'DEFAULT'    &lt;/P&gt;&lt;P&gt;  FETCH NEXT FROM tblfields INTO @fldName, @fldtype, @fldlgth  END --end loop&lt;/P&gt;&lt;P&gt;CLOSE tblfieldsDEALLOCATE tblfieldsPrint ')'&lt;/P&gt;&lt;P&gt;Print ''Print ''Print ''End&lt;/P&gt;&lt;P&gt;if @which = '0' or @which= '4'Beginprint '/* Standard Update for table ' + upper(@tblname) + '*/'Print ''Print ''Print ''Print 'Update ' + upper(@tblname)Print 'SET'Declare tblfields cursor for&lt;/P&gt;&lt;P&gt;SELECT COLUMN_NAME, DATA_TYPE,CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.columns where TABLE_NAME = @tblName order by ORDINAL_POSITION OPEN tblfields FETCH NEXT FROM tblfields INTO @fldName, @fldtype, @fldlgth     WHILE (@@fetch_status &amp;lt;&amp;gt; -1)  BEGIN                if @fldtype&amp;lt;&amp;gt; 'timestamp'       if not @Prefix is null      Print  @fldname + ' =  @' + @Prefix  + @fldname + ','     else      Print  @fldname + ' = @' + @fldname + ','   else    Print @fldname + ' = DEFAULT'    &lt;/P&gt;&lt;P&gt;  FETCH NEXT FROM tblfields INTO @fldName, @fldtype, @fldlgth  END --end loop&lt;/P&gt;&lt;P&gt;CLOSE tblfieldsDEALLOCATE tblfieldsPrint '/* Where statement goes here */' EndSET NOCOUNT Off&lt;/P&gt;&lt;P&gt;SET QUOTED_IDENTIFIER OFF GOSET ANSI_NULLS ON GOexec sp_MS_marksystemobject sp_ScriptHelperGO&lt;/P&gt;</description><pubDate>Thu, 29 Sep 2005 08:07:00 GMT</pubDate><dc:creator>Ted Crafton</dc:creator></item><item><title>RE: Query Analyzer Extended</title><link>http://www.sqlservercentral.com/Forums/Topic214522-247-1.aspx</link><description>&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;For the identifier delimeters (brackets), in Query Analyzer, got Tools|Options and on the Script tab you can choose from,&lt;FONT color=#1111ff&gt;Version dependentNone[] -- 7.0 compatible" " -- 6.5 compatible&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;For point two, I wasn't really expecting you to do anything with your procedure. It was more to do with how things are scripted in query analyzer.&lt;/P&gt;&lt;P&gt;We have a couple of tables that have way too many fields. Most of my adhoc queries on these tables use a majority of the fields in the table and it always seems to be the last few that I end up removing. So I'm constantly finding myself scrolling across to find the fields to delete. &lt;/P&gt;&lt;P&gt;All my user written procedures stay as user procedures whether they perform system functions or not. I do have one stored procedure I put together that generate insert/update/delete procedures for our datawarehouse. I pass in a table name and it does the rest.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description><pubDate>Thu, 29 Sep 2005 07:28:00 GMT</pubDate><dc:creator>philcart</dc:creator></item><item><title>RE: Query Analyzer Extended</title><link>http://www.sqlservercentral.com/Forums/Topic214522-247-1.aspx</link><description>&lt;P&gt;Hi Phill,&lt;/P&gt;&lt;P&gt;thanks for your contribution.&lt;/P&gt;&lt;P&gt;I thought that Enterprise Manager or Query Analyzer always put column names in brackets (on both left and right sides). Your code example does not have brackets. How do you generate this code?&lt;/P&gt;&lt;P&gt;I am willing to improve my procedure. Could you please give me an example on your second comment. I may write one more procedure for this.&lt;/P&gt;&lt;P&gt;Do you create system procedures or functions from user written procedures you like?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Yakov&lt;/P&gt;</description><pubDate>Thu, 29 Sep 2005 06:41:00 GMT</pubDate><dc:creator>yakov shlafman-248344</dc:creator></item><item><title>RE: Query Analyzer Extended</title><link>http://www.sqlservercentral.com/Forums/Topic214522-247-1.aspx</link><description>&lt;P&gt;Hi David,&lt;/P&gt;&lt;P&gt;thanks for comments.&lt;/P&gt;&lt;P&gt;I agree with you... but... this is a procedure that you may use multiple times day after day and year after year ... and the name should be short (Cut typing if you can).&lt;/P&gt;&lt;P&gt;How should I call it? Any ideas for improvement?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Yakov&lt;/P&gt;</description><pubDate>Thu, 29 Sep 2005 06:29:00 GMT</pubDate><dc:creator>yakov shlafman-248344</dc:creator></item><item><title>RE: Query Analyzer Extended</title><link>http://www.sqlservercentral.com/Forums/Topic214522-247-1.aspx</link><description>&lt;P&gt;"&lt;EM&gt;You should be aware - no matter what format you use to create a table Query Analyzer or Enterprise Manager will always return your code in First format&lt;/EM&gt;"&lt;/P&gt;&lt;P&gt;This is not exactly correct. Take a look at the options that can be used for generating scripts.&lt;/P&gt;&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;PRE&gt;&lt;FONT color=#1111ff&gt;CREATE TABLE dbo.Orders ( OrderID int IDENTITY (1, 1) NOT NULL , CustomerID nchar (5) NULL , EmployeeID int NULL , OrderDate datetime NULL , RequiredDate datetime NULL , ShippedDate datetime NULL , ShipVia int NULL , Freight money NULL CONSTRAINT DF_Orders_Freight DEFAULT (0), ShipName nvarchar (40) NULL , ShipAddress nvarchar (60) NULL , ShipCity nvarchar (15) NULL , ShipRegion nvarchar (15) NULL , ShipPostalCode nvarchar (10) NULL , ShipCountry nvarchar (15) NULL)&lt;/FONT&gt;&lt;/PRE&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P dir=ltr&gt;&lt;FONT color=#111111&gt;Not perfect, but more workable.&lt;/FONT&gt;&lt;/P&gt;&lt;P dir=ltr&gt;&lt;FONT color=#111111&gt;The two things I would like to have are,1) Place the comma at the start. Like you have, this makes ad-hoc modification much easier.2) When scripting select/insert/update statements, have the text wrap at a column you've previously specified, or preferably put each column on a new line like the create does.&lt;/FONT&gt;&lt;/P&gt;&lt;P dir=ltr&gt;&lt;FONT color=#111111&gt;&lt;/FONT&gt;&lt;FONT color=#111111&gt; &lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Thu, 29 Sep 2005 01:52:00 GMT</pubDate><dc:creator>philcart</dc:creator></item><item><title>RE: Query Analyzer Extended</title><link>http://www.sqlservercentral.com/Forums/Topic214522-247-1.aspx</link><description>Good idea, good code....terrible name for a stored procedure!</description><pubDate>Thu, 29 Sep 2005 01:04:00 GMT</pubDate><dc:creator>David McKinney</dc:creator></item><item><title>Query Analyzer Extended</title><link>http://www.sqlservercentral.com/Forums/Topic214522-247-1.aspx</link><description>Comments posted to this topic are about the content posted at &lt;A HREF="http://www.sqlservercentral.com/columnists/yShlafman/queryanalyzerextended.asp"&gt;http://www.sqlservercentral.com/columnists/yShlafman/queryanalyzerextended.asp&lt;/A&gt;</description><pubDate>Fri, 26 Aug 2005 11:36:00 GMT</pubDate><dc:creator>Yakov Shlafman</dc:creator></item></channel></rss>