Reputation: 10134
is there a way to define a single long string with line breaks within the string definition code?
my string is somethign like this:
string sql = "SELECT
a.bg_user_56 AS Project,
a.bg_user_60 AS SubSystem,
a.BG_USER_81 AS AssignedToUserName,
a.bg_responsible AS AssignedTo,
FROM mytable"
Upvotes: 3
Views: 1380
Reputation: 38025
The @ sign is great for this, but for SQL, I like to define my SQL as a project resource. This makes it easy to read, update, and open in Query Analyzer (or the T-Sql editor of you choice) and execute.
Upvotes: 0
Reputation: 210402
string sql = @"SELECT a.bg_user_56 AS Project,\r\na.bg_user_60 AS SubSystem,\r\na.BG_USER_81 AS AssignedToUserName,\r\na.bg_responsible AS AssignedTo,\r\nFROM mytable"
Upvotes: 0
Reputation: 498942
Use a verbatim string literal (that begins with a @
):
string sql = @"SELECT
a.bg_user_56 AS Project,
a.bg_user_60 AS SubSystem,
a.BG_USER_81 AS AssignedToUserName,
a.bg_responsible AS AssignedTo,
FROM mytable"
Upvotes: 15