Solved

SQL Server  Select Into  for SQL Guru

Posted on 2009-05-19
5
389 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MS SQL Bulk load data error 5 33
PL/SQL query 14 46
t-sql complement 8 31
SQL query to summarize items per month 5 27
Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how the fundamental information of how to create a table.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now