We dynamically build a sql statement after validation
After running some code the generated values for the insert looks like this:
(1, 1, SYSDATETIME(), null),
(4, 1, SYSDATETIME(), null),
(6, 1, SYSDATETIME(), null),
(8, 1, SYSDATETIME(), null)
Valid SQL Syntax
We then user this as follows
IF(@Activities != null)
Begin
INSERT INTO [User].[User_Activities]
(UserId, ActivitieId, DateCreated, DateDeleted)
VALUES
@Activities
END
@Activities being the above dynamically built SQL statement, its throws an error saying incorrect syntax by @Activities.
Even though in SQL query window it looks like this:
Insert into [User].User_Activities
(UserId, ActivitieId, DateCreated, DateDeleted)
Values
(1, 1, SYSDATETIME(), null),
(4, 1, SYSDATETIME(), null),
(6, 1, SYSDATETIME(), null),
(8, 1, SYSDATETIME(), null)
and executes successfully, how can I make this work successfully via the application?
string s = "Console.WriteLine"; s("hello");