?
Solved

SQL Server  Select Into  for SQL Guru

Posted on 2009-05-19
5
Medium Priority
?
414 Views
Last Modified: 2012-05-07
When I try to run this simple statement (below) I get an error -

Msg 102, Level 15, State 1, Line 4
Incorrect syntax near ')'.

If I run the second select by iytself it works -  Any idea why this would occur -
if i can not use row number to number the items in each set within this larger set how can I accomplish this?  
select id , evtdate, userGuid, Interval, FieldName, value, 
point into #temp2 from (Select id , evtdate, userGuid, Interval, FieldName, value, 
ROW_NUMBER() OVER(Partition By ID  Order By FieldName) from #temp)

Open in new window

0
Comment
Question by:DylanJones1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 2000 total points
ID: 24425036
very close

select id , evtdate, userGuid, Interval, FieldName, value,
point into #temp2 from (Select id , evtdate, userGuid, Interval, FieldName, value,
ROW_NUMBER() OVER(Partition By ID  Order By FieldName) from #temp)a
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 24425043
btw..whenever you do a subquery like that, you have to give it an alias...in the above, i just put an a afterwards....other than that, looks good.
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 24425061
Hello DylanJones1,

You could try this:

select id , evtdate, userGuid, Interval, FieldName, value, IDENTITY(int, 1, 1) AS point
into #temp2
from #temp
order by ID, FieldName

Regards,

Patrick
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 24425066
slow fingers :)
0
 

Author Closing Comment

by:DylanJones1
ID: 31583163
Thanks,  I like slow finders suggestion also  just to avoid the row numbering - did we lose the ability to split points?
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question