March 3, 2006 at 7:02 am
I have the following Select Statement:
SELECT
Cusip,
UserBondFlag,
Par,
Price
FROM TableTest
The Par Value is currently set to all 1s (ones). I want to make it a sequential number starting with 1. What is the best way to accomplish this? May I set Par to an AutoNum Field within the Select Statement or can I use an Update Statement to set par to a sequential number value? I want to start the auto-numbering with the second row in the table because the first row is a header row (I do have a way to distinguish the header row.) We have SQL Server 2000 (SP3). Please provide examples.
Thanks in advance, Kevin
March 3, 2006 at 7:17 am
This kind of thing has been discussed many times before on here. Here's one simple way (as an example)...
CREATE TABLE #T1 (name SYSNAME, par INT IDENTITY(1, 1))
INSERT INTO #T1 SELECT name FROM SYSOBJECTS
SELECT * FROM #T1
DROP TABLE #T1
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
March 3, 2006 at 7:36 am
SELECT IDENTITY(int, 1,1) as ID
Cusip, UserBondFlag, Par, Price
INTO #Table
FROM TableTest
SELECT * FROM #Table
_____________
Code for TallyGenerator
March 3, 2006 at 10:26 am
This is interesting ... A header row? What's that supposed to be good for? Printing?
_/_/_/ paramind _/_/_/
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply