SQL Help?? | Carolina Shooters Club

SQL Help??

Discussion in 'Off Topic Discussion' started by Flashpoint, Nov 5, 2016.

  1. Flashpoint

    Flashpoint Club Subscribed Club Subscribed

    Joined:
    Jan 2, 2008
    Messages:
    3,898
    Location:
    Alamance Co, NC
    Anyone here know SQL? I used to use it 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?

    SQL.PNG

    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!

    SQL2.PNG
     
    Last edited: Nov 5, 2016
  2. B00GER

    B00GER Club Subscribed Club Subscribed

    Joined:
    Jun 25, 2011
    Messages:
    15,599
    Location:
    Lewisville, NC
    I use SQL a bit, but can't mess with it without it in front of me. If this is still jacked up Monday I'll get one of my guys to help.


    Sent from my iPhone using Tapatalk
     
  3. Flashpoint

    Flashpoint Club Subscribed Club Subscribed

    Joined:
    Jan 2, 2008
    Messages:
    3,898
    Location:
    Alamance Co, NC
    Thanks! I have a an interview for a position on Thursday and some light SQL is required. I'll need to know how to do Joins, etc. that I used to do but have forgotten. Hopefully I'll figure it out this weekend. Just registered and posted on an SQL forum and then rrealized there has been no traffic in that forum since July, lol.
     
  4. B00GER

    B00GER Club Subscribed Club Subscribed

    Joined:
    Jun 25, 2011
    Messages:
    15,599
    Location:
    Lewisville, NC
    I've got some links I can send you that I use for basic SQL coding. I'm no expert by far, but my team mates are


    Sent from my iPhone using Tapatalk
     
  5. jerz_subbie

    jerz_subbie Active Member

    Joined:
    Apr 1, 2009
    Messages:
    3,713
    Location:
    Charlotte
    You don't need the brackets around your column names in the insert. And use single quotes around the values.
    If that doesn't work, there must be something different about 2016, I'm still on 2008.
     
    flivver likes this.
  6. bigfutz

    bigfutz Registered Member

    Joined:
    Jul 26, 2012
    Messages:
    199
    Location:
    Upstate SC
    Is SN a numeric or text (VARCHAR) field? On second look, I'm agreeing with the quotes prognosis.
     
  7. BurnedOutGeek

    BurnedOutGeek SlayerNut - RIP

    Joined:
    Mar 24, 2009
    Messages:
    13,354
    Location:
    Gtfo
    I've got nothing to add other than what I told you the other week. I hate sql. Lol
     
    Tyederian likes this.
  8. Mikew

    Mikew Well-Known Member

    Joined:
    Jan 10, 2014
    Messages:
    4,679
    Location:
    High Point,NC
    I thought this was going to be recipes for tree rats.
     
  9. WNC Seabee

    WNC Seabee Lifetime Member Lifetime Member

    Joined:
    Oct 15, 2008
    Messages:
    12,035
    Location:
    Henderson County, NC
    Been a while since I've done this, but I also think it's the single quote. Also, Is that back slash in 22/45 an issue?
     
  10. flivver

    flivver Club Subscribed Club Subscribed

    Joined:
    Jul 17, 2009
    Messages:
    690
    Location:
    Central NC
    I'd quote the serial number, too. Otherwise, you're apt to get some kind of a numeric conversion. An 11 digit number doesn't fit in a normal int. The 10 digit number you've got if you strip the leading 0 does, but again, better to just quote it since it's really a string.
     
    jerz_subbie likes this.
  11. Flashpoint

    Flashpoint Club Subscribed Club Subscribed

    Joined:
    Jan 2, 2008
    Messages:
    3,898
    Location:
    Alamance Co, NC
    Thank you! I had tried both of those suggestions, but obviously not both together! ;) All is well now. It amazes me how many examples and syntax formats I found and none were exactly as you described, but which is obviously correct! Thanks jerz and everyone, once again the CSC brain trust rules!!

    Another thing that through me off is that the 2016 MSSMS editor flags the single quoted strings in red!
     
    Last edited: Nov 6, 2016
    jerz_subbie likes this.
  12. Flashpoint

    Flashpoint Club Subscribed Club Subscribed

    Joined:
    Jan 2, 2008
    Messages:
    3,898
    Location:
    Alamance Co, NC
    Both of you are correct. That was an oversight on my part, it is meant to be a string I just forgot to quote it.
     
  13. jerz_subbie

    jerz_subbie Active Member

    Joined:
    Apr 1, 2009
    Messages:
    3,713
    Location:
    Charlotte
    I get the same in 2008. It'll flag certain things that I know are correct, which is why I teach coworkers that the red underlines are "strong clues" that something might be wrong nearby.

    Glad to hear you got it worked out though! I find stackoverflow to be the best resource if you google your issue.
     
  14. Qball50

    Qball50 Lifetime Member Lifetime Member

    Joined:
    Mar 18, 2010
    Messages:
    9,686
    Location:
    High Point, NC
    I'm not sure. It appears to me that HAL doesn't like Ruger 10/22s. Not quite sure though.:D
     

Share This Page