Solved

SQL Server  Select Into  for SQL Guru

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Running total between 2 sql tables in Sql 6 45
sql server connection string in config file 4 35
Remove () 9 34
SQL Query 9 24
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

738 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