Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Darts75
Starting Member
27 Posts |
Posted - 2014-10-29 : 23:52:16
|
Hi Everyone,I am new to Dynamic SQL and have become quite stuck regarding how to included aliases which have spaces in my query. A related issue, which I believe also revolves around the use of single talking marks (') within Dynamic SQL is how to include argument values and variables in my queries.From my limited research it 'feels like' what I need to do is the opposite of ESCAPE sequencing...My issue is better explained through some code samples.Each of the samples below assume the use of a variable within the overall query, e.g.: DECLARE @SQL nvarchar(max)Here is a sample from a working query (excuse the brevity)Now if I put a space into the Alias name as shown below the query will not run...Similarly I am wondering how to go about assigning variables, within for example a WHERE clause?Any help with the above broad questions will be greatly appreciated.Kind Regards,Davo |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-10-30 : 09:23:51
|
Please do not imbed screenshots as samples. Include the code directly in your post. At my company, those screenshots are blocked by the content filter. Plus, with screenshots, one has to retype the code to try it out. |
|
|
|
|
|