<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: from code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 07 Sep 2008 03:51:33 GMT</pubDate>
    <description>DZone Snippets: from code</description>
    <item>
      <title>MSSQL 2005 - Add ID value to ID column when INSERTING </title>
      <link>http://snippets.dzone.com/posts/show/4521</link>
      <description>// @TableName is obviously the TABLE name u use&lt;br /&gt;// @ColumnName is obviously the COLUMN name u use&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;---Get next ID number&lt;br /&gt;	DECLARE &lt;br /&gt;		@ID int&lt;br /&gt;	&lt;br /&gt;	IF (SELECT count(*) FROM @TableName ) &gt; 0&lt;br /&gt;		BEGIN&lt;br /&gt;			SELECT @ID  = max(ColumnName ) from @TableName&lt;br /&gt;			SET @ID = @ID + 1 &lt;br /&gt;		END&lt;br /&gt;	ELSE&lt;br /&gt;	BEGIN&lt;br /&gt;		SET @ID  = 1&lt;br /&gt;	END&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 11 Sep 2007 07:50:29 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4521</guid>
      <author>dubby (Dave)</author>
    </item>
  </channel>
</rss>
