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 |
|
ann
Posting Yak Master
220 Posts |
Posted - 2006-06-23 : 15:16:20
|
| Sorry to ask so many questions, but I am new to this. I am writing a dynamic sp for purposes of bi-directional sorting in a datagrid. I have everything working...except I am having issues with the Assign, (it's a varchar) - if I take out that line, it works fine: ' AND AssignedTo = ' + @Assign + ' ORDER BY ' + @SortColumn + ' ' + @Direction Can anyone help? Thanks! |
|
|
VladRUS.ca
Starting Member
23 Posts |
Posted - 2006-06-23 : 15:50:34
|
| Try this:' AND AssignedTo = ''' + @Assign + ''''' ORDER BY ' + @SortColumn + ' ' + @Direction |
 |
|
|
ann
Posting Yak Master
220 Posts |
Posted - 2006-06-23 : 15:56:38
|
| Thanks that worked - I appreciate you taking the time to help me!I hate always asking others, so I always try to find answers first - but I cannot find any resource on how to handle these type of syntax issues ... would you know where I might find something? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-06-23 : 16:04:01
|
| ann,The best way to troubleshoot is to print out the variable where you are storing your query. DECLARE @SQL varchar(4000), @TableName nvarchar(256)SET @TableName = 'sysobjects'SET @SQL = 'SELECT * FROM ' + @TableNamePRINT @SQLDo not add the EXEC part into your code until @SQL looks how you want it. By printing it, you can verify that you have all of the singles quotes in the right place.Tara Kizeraka tduggan |
 |
|
|
ann
Posting Yak Master
220 Posts |
Posted - 2006-06-23 : 18:16:17
|
| Thanks - I will try that :) |
 |
|
|
|
|
|