Timeline for Is there a way to execute SQL statement based on SQL Server version?
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 12, 2016 at 7:06 | comment | added | vonPryz |
@Massimo exec is a sledgehammer that executes anything that goes. sp_executesql is more strict about the input. See more at SqlSkills' blog
|
|
Jan 29, 2014 at 17:46 | comment | added | Massimo |
Why not just exec '<SQL Query>' ? What's the difference with exec sp_executeSQL '<Same SQL Query>' ?
|
|
Jan 29, 2014 at 15:17 | comment | added | Aaron Bertrand |
Slightly simpler to only define the repeated portion of the index once, and less prone to mistakes if you later decide to change the name/columns etc. (you might forget to change it in both places). SET @sql = N'CREATE ...'; IF (version check) SET @sql = @sql + ' WHERE ...';
|
|
Jan 29, 2014 at 15:07 | history | edited | JNK | CC BY-SA 3.0 |
added 545 characters in body
|
Jan 29, 2014 at 13:08 | vote | accept | Dragan Matic | ||
Jan 29, 2014 at 13:03 | history | answered | kodyaz | CC BY-SA 3.0 |