(205,'ES','西班牙'), (206,'LK','斯里兰卡'), (207,' SD','苏丹'), (208,'SR','苏里南'), (209,'SJ','Svalbard和Jan Mayen Islands' ), (210,'SZ','斯威士兰'), (211,'SE','瑞典'), (212,'CH','瑞士'), (213,'SY','叙利亚'), (214,'TW','台湾' ), (215,'TJ','塔吉克斯坦'), (216,'TZ','坦桑尼亚'), (217,'TH','泰国'), (218,'TG','Togo'), (219,'TK' ,'托克劳'), (220,'TO','汤加'), (221,'TT','特立尼达和多巴哥'), (222,'TN','突尼斯'), (223,'TR','土耳其'), (224,' TM','土库曼斯坦'), (225,'TC','特克斯和凯科斯群岛'), (226,'电视','图瓦卢') , (227,'UG','乌干达'), (228,'UA','乌克兰'), ( 229,'AE','阿拉伯联合酋长国'), (230,'GB','英国'), (231,'美国','美国'), (232,'UM','美国本土外小岛'), (233,'UY','乌拉圭'), b $ b(234,'UZ','乌兹别克斯坦'), (235,'VU','瓦努阿图'), (236, 'VA','梵蒂冈城(罗马教廷)'), (237,'VE','委内瑞拉'), (238,'VN', '越南'), (239,'VG','维尔京群岛(英国) '), (240,'VI','维尔京群岛(美国)'), (241,'WF','瓦利斯和富图纳群岛'), (242,'EH','西撒哈拉'), (243,'YE','也门'), ( 244,'YU','南斯拉夫'), (245,'ZM','赞比亚'), (246,'ZW','Zimbabwe') ; 我尝试了什么: 你好先生我想要在国家/地区表格中插入数据但是当我尝试收到错误时 消息102,级别15,状态1,行5 语法不正确','。 id int已检查 sortname varchar(3)已检查 名称varchar(150)选中INSERT INTO countries (id, sortname, name) VALUES(1, 'AF', 'Afghanistan'),(2, 'AL', 'Albania'),(3, 'DZ', 'Algeria'),(4, 'AS', 'American Samoa'),(5, 'AD', 'Andorra'),(6, 'AO', 'Angola'),(7, 'AI', 'Anguilla'),(8, 'AQ', 'Antarctica'),(9, 'AG', 'Antigua And Barbuda'),(10, 'AR', 'Argentina'),(11, 'AM', 'Armenia'),(12, 'AW', 'Aruba'),(13, 'AU', 'Australia'),(14, 'AT', 'Austria'),(15, 'AZ', 'Azerbaijan'),(16, 'BS', 'Bahamas The'),(17, 'BH', 'Bahrain'),(18, 'BD', 'Bangladesh'),(19, 'BB', 'Barbados'),(20, 'BY', 'Belarus'),(21, 'BE', 'Belgium'),(22, 'BZ', 'Belize'),(23, 'BJ', 'Benin'),(24, 'BM', 'Bermuda'),(25, 'BT', 'Bhutan'),(26, 'BO', 'Bolivia'),(27, 'BA', 'Bosnia and Herzegovina'),(28, 'BW', 'Botswana'),(29, 'BV', 'Bouvet Island'),(30, 'BR', 'Brazil'),(31, 'IO', 'British Indian Ocean Territory'),(32, 'BN', 'Brunei'),(33, 'BG', 'Bulgaria'),(34, 'BF', 'Burkina Faso'),(35, 'BI', 'Burundi'),(36, 'KH', 'Cambodia'),(37, 'CM', 'Cameroon'),(38, 'CA', 'Canada'),(39, 'CV', 'Cape Verde'),(40, 'KY', 'Cayman Islands'),(41, 'CF', 'Central African Republic'),(42, 'TD', 'Chad'),(43, 'CL', 'Chile'),(44, 'CN', 'China'),(45, 'CX', 'Christmas Island'),(46, 'CC', 'Cocos (Keeling) Islands'),(47, 'CO', 'Colombia'),(48, 'KM', 'Comoros'),(49, 'CG', 'Congo'),(50, 'CD', 'Congo The Democratic Republic Of The'),(51, 'CK', 'Cook Islands'),(52, 'CR', 'Costa Rica'),(53, 'CI', 'Cote D''Ivoire (Ivory Coast)'),(54, 'HR', 'Croatia (Hrvatska)'),(55, 'CU', 'Cuba'),(56, 'CY', 'Cyprus'),(57, 'CZ', 'Czech Republic'),(58, 'DK', 'Denmark'),(59, 'DJ', 'Djibouti'),(60, 'DM', 'Dominica'),(61, 'DO', 'Dominican Republic'),(62, 'TP', 'East Timor'),(63, 'EC', 'Ecuador'),(64, 'EG', 'Egypt'),(65, 'SV', 'El Salvador'),(66, 'GQ', 'Equatorial Guinea'),(67, 'ER', 'Eritrea'),(68, 'EE', 'Estonia'),(69, 'ET', 'Ethiopia'),(70, 'XA', 'External Territories of Australia'),(71, 'FK', 'Falkland Islands'),(72, 'FO', 'Faroe Islands'),(73, 'FJ', 'Fiji Islands'),(74, 'FI', 'Finland'),(75, 'FR', 'France'),(76, 'GF', 'French Guiana'),(77, 'PF', 'French Polynesia'),(78, 'TF', 'French Southern Territories'),(79, 'GA', 'Gabon'),(80, 'GM', 'Gambia The'),(81, 'GE', 'Georgia'),(82, 'DE', 'Germany'),(83, 'GH', 'Ghana'),(84, 'GI', 'Gibraltar'),(85, 'GR', 'Greece'),(86, 'GL', 'Greenland'),(87, 'GD', 'Grenada'),(88, 'GP', 'Guadeloupe'),(89, 'GU', 'Guam'),(90, 'GT', 'Guatemala'),(91, 'XU', 'Guernsey and Alderney'),(92, 'GN', 'Guinea'),(93, 'GW', 'Guinea-Bissau'),(94, 'GY', 'Guyana'),(95, 'HT', 'Haiti'),(96, 'HM', 'Heard and McDonald Islands'),(97, 'HN', 'Honduras'),(98, 'HK', 'Hong Kong S.A.R.'),(99, 'HU', 'Hungary'),(100, 'IS', 'Iceland'),(101, 'IN', 'India'),(102, 'ID', 'Indonesia'),(103, 'IR', 'Iran'),(104, 'IQ', 'Iraq'),(105, 'IE', 'Ireland'),(106, 'IL', 'Israel'),(107, 'IT', 'Italy'),(108, 'JM', 'Jamaica'),(109, 'JP', 'Japan'),(110, 'XJ', 'Jersey'),(111, 'JO', 'Jordan'),(112, 'KZ', 'Kazakhstan'),(113, 'KE', 'Kenya'),(114, 'KI', 'Kiribati'),(115, 'KP', 'Korea North'),(116, 'KR', 'Korea South'),(117, 'KW', 'Kuwait'),(118, 'KG', 'Kyrgyzstan'),(119, 'LA', 'Laos'),(120, 'LV', 'Latvia'),(121, 'LB', 'Lebanon'),(122, 'LS', 'Lesotho'),(123, 'LR', 'Liberia'),(124, 'LY', 'Libya'),(125, 'LI', 'Liechtenstein'),(126, 'LT', 'Lithuania'),(127, 'LU', 'Luxembourg'),(128, 'MO', 'Macau S.A.R.'),(129, 'MK', 'Macedonia'),(130, 'MG', 'Madagascar'),(131, 'MW', 'Malawi'),(132, 'MY', 'Malaysia'),(133, 'MV', 'Maldives'),(134, 'ML', 'Mali'),(135, 'MT', 'Malta'),(136, 'XM', 'Man (Isle of)'),(137, 'MH', 'Marshall Islands'),(138, 'MQ', 'Martinique'),(139, 'MR', 'Mauritania'),(140, 'MU', 'Mauritius'),(141, 'YT', 'Mayotte'),(142, 'MX', 'Mexico'),(143, 'FM', 'Micronesia'),(144, 'MD', 'Moldova'),(145, 'MC', 'Monaco'),(146, 'MN', 'Mongolia'),(147, 'MS', 'Montserrat'),(148, 'MA', 'Morocco'),(149, 'MZ', 'Mozambique'),(150, 'MM', 'Myanmar'),(151, 'NA', 'Namibia'),(152, 'NR', 'Nauru'),(153, 'NP', 'Nepal'),(154, 'AN', 'Netherlands Antilles'),(155, 'NL', 'Netherlands The'),(156, 'NC', 'New Caledonia'),(157, 'NZ', 'New Zealand'),(158, 'NI', 'Nicaragua'),(159, 'NE', 'Niger'),(160, 'NG', 'Nigeria'),(161, 'NU', 'Niue'),(162, 'NF', 'Norfolk Island'),(163, 'MP', 'Northern Mariana Islands'),(164, 'NO', 'Norway'),(165, 'OM', 'Oman'),(166, 'PK', 'Pakistan'),(167, 'PW', 'Palau'),(168, 'PS', 'Palestinian Territory Occupied'),(169, 'PA', 'Panama'),(170, 'PG', 'Papua new Guinea'),(171, 'PY', 'Paraguay'),(172, 'PE', 'Peru'),(173, 'PH', 'Philippines'),(174, 'PN', 'Pitcairn Island'),(175, 'PL', 'Poland'),(176, 'PT', 'Portugal'),(177, 'PR', 'Puerto Rico'),(178, 'QA', 'Qatar'),(179, 'RE', 'Reunion'),(180, 'RO', 'Romania'),(181, 'RU', 'Russia'),(182, 'RW', 'Rwanda'),(183, 'SH', 'Saint Helena'),(184, 'KN', 'Saint Kitts And Nevis'),(185, 'LC', 'Saint Lucia'),(186, 'PM', 'Saint Pierre and Miquelon'),(187, 'VC', 'Saint Vincent And The Grenadines'),(188, 'WS', 'Samoa'),(189, 'SM', 'San Marino'),(190, 'ST', 'Sao Tome and Principe'),(191, 'SA', 'Saudi Arabia'),(192, 'SN', 'Senegal'),(193, 'RS', 'Serbia'),(194, 'SC', 'Seychelles'),(195, 'SL', 'Sierra Leone'),(196, 'SG', 'Singapore'),(197, 'SK', 'Slovakia'),(198, 'SI', 'Slovenia'),(199, 'XG', 'Smaller Territories of the UK'),(200, 'SB', 'Solomon Islands'),(201, 'SO', 'Somalia'),(202, 'ZA', 'South Africa'),(203, 'GS', 'South Georgia'),(204, 'SS', 'South Sudan'),(205, 'ES', 'Spain'),(206, 'LK', 'Sri Lanka'),(207, 'SD', 'Sudan'),(208, 'SR', 'Suriname'),(209, 'SJ', 'Svalbard And Jan Mayen Islands'),(210, 'SZ', 'Swaziland'),(211, 'SE', 'Sweden'),(212, 'CH', 'Switzerland'),(213, 'SY', 'Syria'),(214, 'TW', 'Taiwan'),(215, 'TJ', 'Tajikistan'),(216, 'TZ', 'Tanzania'),(217, 'TH', 'Thailand'),(218, 'TG', 'Togo'),(219, 'TK', 'Tokelau'),(220, 'TO', 'Tonga'),(221, 'TT', 'Trinidad And Tobago'),(222, 'TN', 'Tunisia'),(223, 'TR', 'Turkey'),(224, 'TM', 'Turkmenistan'),(225, 'TC', 'Turks And Caicos Islands'),(226, 'TV', 'Tuvalu'),(227, 'UG', 'Uganda'),(228, 'UA', 'Ukraine'),(229, 'AE', 'United Arab Emirates'),(230, 'GB', 'United Kingdom'),(231, 'US', 'United States'),(232, 'UM', 'United States Minor Outlying Islands'),(233, 'UY', 'Uruguay'),(234, 'UZ', 'Uzbekistan'),(235, 'VU', 'Vanuatu'),(236, 'VA', 'Vatican City State (Holy See)'),(237, 'VE', 'Venezuela'),(238, 'VN', 'Vietnam'),(239, 'VG', 'Virgin Islands (British)'),(240, 'VI', 'Virgin Islands (US)'),(241, 'WF', 'Wallis And Futuna Islands'),(242, 'EH', 'Western Sahara'),(243, 'YE', 'Yemen'),(244, 'YU', 'Yugoslavia'),(245, 'ZM', 'Zambia'),(246, 'ZW', 'Zimbabwe');What I have tried:hello sir i want to insert data in countries table but when i attempt i getting errorMsg 102, Level 15, State 1, Line 5Incorrect syntax near ','.idintCheckedsortnamevarchar(3)Checkednamevarchar(150)Checked推荐答案我刚刚通过SSMS检查了它,创建了一个三列表并将SQL粘贴到一个新查询中,它执行得很好 - 246行受影响。 检查您的代码,并确保它完全匹配你发布了。 如果你确定它确实如此,撕掉它的一半并尝试剩下的东西。如果有效,请将其撕掉并更换您删除的原始位。如果失败了,请重复直到你把它归结为几行 - 那么它应该更加明显。I just checked it here via SSMS by creating a three column table and pasting your SQL into a new query, and it executes fine - 246 row(s) affected.Check your code, and make sure that it exactly matches what you posted.If you're sure it does, rip out half of it and try what's left. If it work, rip it out and replace the original bit you removed. If that fails, repeat until you get it down to a couple of lines - it should be more obvious then. 我认为问题在于你在Hi,I think the problem is with the apostrofe (') sign, that you have at(53, 'CI', 'Cote D''Ivoire (Ivory Coast)'), 尝试插入该行之前的所有国家/地区。 如果您从网络复制文本,则可能包含不可打印的字符Try to INSERT all countries that are before that line.If you copied text from web it may contains unprintable characters我同意其他人的意见,我看不到您发布的SQL脚本的问题。但是,您发布的错误消息显示','第5行附近的语法不正确 您从哪里运行此SQL? 如果您使用的是SQL管理工作室,则可以双击错误消息,它将突出显示错误行。如果你还没有打开行号也会有帮助。 工具 - >选项 - >文字编辑器 - >所有语言 - >显示部分 - >行号 祝你好运,希望你解决问题。I agree with everyone else, I cannot see an issue with the SQL script that you have posted. However the error message you posted says incorrect syntax near ',' Line 5Where are you running this SQL from ?If you are using SQL management Studio, you can double click the error message and it will highlight the line with the error on it. Also turn on the line numbers if you haven't already this will also help.Tools -> options -> Text Editor -> All Languages-> Display section -> Line numbersGood luck hope you resolve your issue. 这篇关于在SQL中插入数据获取语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-12 03:29