Solved

SQL Server  Select Into  for SQL Guru

Posted on 2009-05-19
5
402 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
  • 2
  • 2
5 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 500 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 92

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 92

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

821 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