1

I am using C# to add extended properties to the tables in my database. When I use a SQL editor, this code works, as each statement is on a new line. However, when creating the command as a string in C#, I get 'Incorrect syntax near GO' twice in the same error message. How can I write this out so that c# executes it on seperate lines or in the correct syntax?

USE UserList; 
GO EXEC sys.sp_addextendedproperty 
@name = N'Description', 
@value=N'some text', 
@level0type=N'SCHEMA', @level0name=N'dbo', 
@level1type=N'TABLE', 
@level1name=N'table_name'
GO
3
  • 4
    GO is a hint for SQL Management Studio, see stackoverflow.com/questions/40814/… and others Commented Feb 12, 2014 at 16:35
  • Also, using @ before your string literal lets you use multiline queries without adding special characters. Commented Feb 12, 2014 at 16:37
  • Took out the GO and now it works flawlessly, thanks guys. Make an answer and I'll accept it. Commented Feb 12, 2014 at 16:48

1 Answer 1

1
USE UserList; 
GO         --<-- Go key word should be on it own in a line nothing before or after 

EXEC sys.sp_addextendedproperty 
@name = N'Description', 
@value=N'some text', 
@level0type=N'SCHEMA', @level0name=N'dbo', 
@level1type=N'TABLE', 
@level1name=N'table_name'
GO
Sign up to request clarification or add additional context in comments.

1 Comment

This shows you hardly read my question or following comments.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.