Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Writing SQL to new table
Message
De
11/06/2008 19:36:59
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
11/06/2008 19:32:00
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01323209
Message ID:
01323341
Vues:
16
This message has been marked as the solution to the initial question of the thread.
>>>>>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'.
>>>
>>
>>
>>Select Distinct  (P.ChartID),
>>		'0' AS Processed
>>Into NTSERVER.IMPACTMD.dbo.ChartID
>>   From NTSERVER.IMPACTMD.dbo.Patients P
>>			Inner Join NTSERVER.IMPACTMD.dbo.Doc_Header H
>>				On H.PatientID = P.PatientID
>>
Cetin
>
>The INTO had to come before the FROM?

Yes, it is SQL server syntax.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform