Allen Pitts
asked on
T-SQL Import data in Microsoft SQL Server Management Studio using INSERT
Hello expert,
I work for a healthcare company so we have old tools, SSMS ver 9 and SQL Server 2005.
Have question open on a similar topic and will close that question if I can get an answer that works.
While I was waiting I figured I would try importing the data into the table using the old fashion method: INSERT
The syntax was derived from
https://technet.microsoft.com/en-us/library/dd776381(v=sql.105).aspx
and this script was written
USE TempData;
GO
INSERT INTO SFA.tempCrossInsurance
VALUES (377332, 'City of Auburn', 'Injury Care', 1832030, 207120, '', 98, 'Maine',1269046021)
This works and inserts the values. But I need more than one row so following
the example this was tried
USE TempData;
GO
INSERT INTO SFA.tempCrossInsurance
VALUES (377332, 'City of Auburn', 'Injury Care', 1832030, 207120, '', 98, 'Maine',1269046021),
(288461, 'Lepage Bakeries', 'Injury Care', 1347245, 207119,'', 104, 'Rhode Island', 1259048689)
This returns
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near ','.
Not very meaningful. I think the comma in the message is the one at the end of the first group of values.
Also tried stringing the values out into a single line and several other variations such
as removing the comma between the groups of values.
I have studied the example for some time
but I don't see a difference between my script and the example.
Any idea why it is complaining about the comma?
Thanks.
Allen in Dallas
I work for a healthcare company so we have old tools, SSMS ver 9 and SQL Server 2005.
Have question open on a similar topic and will close that question if I can get an answer that works.
While I was waiting I figured I would try importing the data into the table using the old fashion method: INSERT
The syntax was derived from
https://technet.microsoft.com/en-us/library/dd776381(v=sql.105).aspx
and this script was written
USE TempData;
GO
INSERT INTO SFA.tempCrossInsurance
VALUES (377332, 'City of Auburn', 'Injury Care', 1832030, 207120, '', 98, 'Maine',1269046021)
This works and inserts the values. But I need more than one row so following
the example this was tried
USE TempData;
GO
INSERT INTO SFA.tempCrossInsurance
VALUES (377332, 'City of Auburn', 'Injury Care', 1832030, 207120, '', 98, 'Maine',1269046021),
(288461, 'Lepage Bakeries', 'Injury Care', 1347245, 207119,'', 104, 'Rhode Island', 1259048689)
This returns
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near ','.
Not very meaningful. I think the comma in the message is the one at the end of the first group of values.
Also tried stringing the values out into a single line and several other variations such
as removing the comma between the groups of values.
I have studied the example for some time
but I don't see a difference between my script and the example.
Any idea why it is complaining about the comma?
Thanks.
Allen in Dallas
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
Bcp is a command available or use bulk insert
https://technet.microsoft.com/en-us/library/ms188365(v=sql.110).aspx
Look at a Dts to load/import the data.