| Author |
Topic |
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2010-06-24 : 08:32:16
|
| Here's my sp - what's the syntax to tag an ORDER BY ReqDate asc on the endSELECT @SQLStatement = "SELECT * FROM tblOrders WHERE " + @WHEREClause |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-06-24 : 08:34:12
|
SELECT @SQLStatement = 'SELECT * FROM tblOrders WHERE ' + @WHEREClause + ' ORDER BY ReqDate asc' No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2010-06-24 : 08:49:34
|
| I am now getting an error, but the column is correct and exists in the view. I had to change the ' to " marksInvalid column name 'ORDER BY ReqDate asc'. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-06-24 : 08:51:55
|
| What is the result of print @SQLStatement ?MadhivananFailing to plan is Planning to fail |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-06-24 : 08:52:10
|
use single quotes No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2010-06-24 : 08:58:45
|
| It goes red then |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-06-24 : 08:59:54
|
quote: Originally posted by Pinto It goes red then
Can you post the actual statement that caused error?MadhivananFailing to plan is Planning to fail |
 |
|
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2010-06-24 : 09:02:13
|
| SELECT @SQLStatement = "SELECT * FROM tblOrders WHERE " + @WHEREClause + "ORDER BY ReqDate asc" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-06-24 : 09:10:42
|
| Change double quotes to single quoteMadhivananFailing to plan is Planning to fail |
 |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-06-24 : 09:11:00
|
| What o/p does Print(@SQLStatement)give?Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH |
 |
|
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2010-06-24 : 09:13:13
|
| How do I run that ?Print(@SQLStatement)give |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-06-24 : 09:15:42
|
just do a print @SQLStatementor you can do alsoselect @SQLStatement No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-06-24 : 09:17:10
|
quote: Originally posted by Pinto How do I run that ?Print(@SQLStatement)give
Have you seen my previous reply?MadhivananFailing to plan is Planning to fail |
 |
|
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2010-06-24 : 09:21:07
|
| Yes, I did and I have just done that and it compiles ok. Thanks |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-06-24 : 09:22:26
|
quote: Originally posted by Pinto It goes red then
Yes. Literals in single quotes are displayed in red and that is ok! No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|