Mensaje
 
a
11/06/2008 15:47:02
Jay Johengen
Altamahaw-Ossipee, Carolina del Norte, United States
General information
Foro:
Microsoft SQL Server
Category:
Sintáxis SQL
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
ID de la conversación:
01323209
ID del mensaje:
01323326
Views:
15
>>>It looks like I can't select from a cursor in SQL Server - If I can, tell me how - so, I need to write the results of a SQL to a table in the existing database. Then I can run SQL against that. How do I do that?
>>
>>Look at INSERT ... SELECT syntax (the same as in VFP, if I recall correctly).
>>
>>If you need to create a new table, then you also can use INTO TABLE syntax of SELECT-SQL. The catch is to put INTO TABLE right after the FROM keyword, not after WHERE as in VFP.
>
>This returns an error (see below the SQL):
>
>
>	Select Distinct
>		(P.ChartID),
>		'0' AS Processed
>		From NTSERVER.IMPACTMD.dbo.Patients P
>		Into Table NTSERVER.IMPACTMD.dbo.ChartID
>			Inner Join NTSERVER.IMPACTMD.dbo.Doc_Header H
>				On H.PatientID = P.PatientID
>
>
>
>Msg 156, Level 15, State 1, Line 44
>Incorrect syntax near the keyword 'Into'.
>
I think JOINS should preceed INTO clause.
If it's not broken, fix it until it is.


My Blog
Previous
Responder
Mapa
Ver