I want to update a column in a table 1 to 10000
which is the best method for doing this.
Environment: Sql Server 2008.
I thought a may be
USE []
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[mytable](
[userid] [int] NULL,
[name] [nchar](10) NULL
) ON [PRIMARY]
GO
insert into mytable(userid,name)Values (1,'a')
insert into mytable(userid,name)Values (6,'b')
insert into mytable(userid,name)Values (7,'c')
insert into mytable(userid,name)Values (8,'d')
insert into mytable(userid,name)Values (9,'e')
GO
then an error msg56, Level 15, State 1, Line 2
Incorrect syntax near the keyword ‘INTO’.
USE MD
SELECT userid = 0, * FROM mytable INTO #tmp_data
DECLARE @userid int
SET @userid = 0
UPDATE #tmp_data
SET @userid= userid = @userid + 1
where have I gone wrong
The syntax is
The UPDATE statement does not look correct, either. But I have no idea what you are trying to achieve.