12

It's about SQL Server 2012 Management Studio. I'm training my SQL skills as manually create queries.

Now I want to insert several records in the Users table. As you see there exists a column GroupID, which is a foreign key to another table Groups.

enter image description here

However when I write a query:

insert into Users (Username, Pass, FullName, GroupID)
values ('Tyana', '17890', 'Tyana Stoyanov', 4)

I get an error:

Invalid column name GroupID

enter image description here

Why is that?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Todo
  • 657
  • 1
  • 10
  • 24
  • 7
    After adding new columns you need to refresh the intellisense cache to have them picked up. Possible duplicate of [SQL Server 2008 Intellisense problem](http://stackoverflow.com/questions/7215211/sql-server-2008-intellisense-problem) – Martin Smith Jul 14 '13 at 11:05
  • 1
    Yeah, this was it!!! I didn't know this option, though I even tried Disconnect/Connect with no success. Thanks! – Todo Jul 14 '13 at 11:12
  • 2
    +1 for a well presented question. – Martin Smith Jul 14 '13 at 11:16

3 Answers3

5

Ctrl + Shift + R is the hotkey to refresh Intellisense. It should fix the problem.

Nathan
  • 503
  • 3
  • 10
0

Have you tried [GroupID]? I meant whether or not you tried using brackets? Also, are you sure that GroupID is not an auto incremental field or something similar?

Arash
  • 3,628
  • 5
  • 46
  • 70
0

Have you tried executing this? I think it will execute properly. The error is indicated only because of non-refreshed intellisense.

Gaurav Karwal
  • 116
  • 2
  • 10