Tom Moreau
3/18/2007 9:48:00 PM
Ok, try:
insert MyTable
(
Col1, Col2, Col3
)
select
max (Col1) + 1, 'blah', 'blah'
from
MyTable
--
Tom
----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
"geoffa" <geoffa@discussions.microsoft.com> wrote in message
news:8A8BDDCC-8911-4A75-89D0-3D3B0177F82A@microsoft.com...
its the same table. i am bascially wanting to programatically add a value of
1 to each insert to an already existing integer column. so when col1 = 123,
the next insert would insert 124 into col1.
"Tom Moreau" wrote:
> Can you be more specific? If you want to insert data from another table,
> try:
>
> insert MyTable
> (
> Col1, Col2, Col3
> )
> select
> ColA, ColB, ColC
> from
> MyOtherTable
>
> --
> Tom
>
> ----------------------------------------------------
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Toronto, ON Canada
>
> "geoffa" <geoffa@discussions.microsoft.com> wrote in message
> news:E3426D0E-0110-42C2-8044-DD61A96D819B@microsoft.com...
> how can i insert a row and increase the value of an integer field by one.
> there is no identity column and i cannot add one. i need to do something
> like,
>
> DECLARE @myvar varchar(8)
> SET @myvar = col1 +1
>
> INSERT mytable
> VALUES ('@myvar', 'NULL', 'whatever')
> GO
>
> thanks....
>
> col1 value would always be in Row(0) from a previous query or a temp table
> ....
>
>
>
>