SQL Basics

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDatabasesSQL Basics

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old November 5th, 2016, 10:57 PM
AutoX AutoX is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Nov 2016
Posts: 1 AutoX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 3 sec
Reputation Power: 0
Please help with simple INSERT

I used to use SQL sparingly in a job 8 years ago and I'm trying to get back into it. I just installed SQL Server 2016 and am playing around in MSSMS trying to get started. Can you please tell me why the below returns the error it does?

CREATE Table Handguns
(ID INT NOT NULL IDENTITY PRIMARY KEY,
Manufacturer varchar(50),
Model varchar(25),
Caliber varchar(25),
Capacity INT,
SN varchar(30)
)

INSERT INTO Handguns [(Manufacturer, Model, Caliber, Capacity, SN)]
VALUES ("Ruger", "22/45TB", "22lr", 10, 01234567890);

Msg 102, Level 15, State 1, Line 10
Incorrect syntax near '(Manufacturer, Model, Caliber, Capacity, SN)'.



If I get rid of the brackets in the INSERT line above it makes it past that line but then takes the VALUES input as column names. I've looked all over for other syntax examples and still cannot figure out what stupid thing I am doing wrong. Thanks!

INSERT INTO Handguns (Manufacturer, Model, Caliber, Capacity, SN)
VALUES ("Ruger", "22/45TB", "22lr", 10, 01234567890);

Msg 207, Level 16, State 1, Line 10
Invalid column name 'Ruger'.
Msg 207, Level 16, State 1, Line 10
Invalid column name '22/45TB'.
Msg 207, Level 16, State 1, Line 10
Invalid column name '22lr'.

Reply With Quote
  #2  
Old November 10th, 2016, 03:29 PM
DMo2 DMo2 is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Nov 2016
Posts: 2 DMo2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 20 sec
Reputation Power: 0
Try changing the double tick " to a single tick '.

Reply With Quote
  #3  
Old January 25th, 2017, 06:17 AM
Rashmi.Padia Rashmi.Padia is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jan 2017
Location: Ahmedabad
Posts: 24 Rashmi.Padia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 8 m 8 sec
Reputation Power: 0
Simple Insert

Hi,

Try this Query for insert a record,

Code:

INSERT INTO TABLE_NAME(COLUMN_NAME1,COLUMN_NAME2,COLUMN_NAME3)  
VALUES('VALUE1','VALUE2','VALUE3')



Thanks,

Reply With Quote
Reply

Viewing: Tutorialized ForumsDatabasesSQL Basics > Please help with simple INSERT


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap