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.

 All Forums
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 SELECT TOP and asp.net

Author  Topic 

barryman9000
Starting Member

4 Posts

Posted - 2007-03-07 : 13:13:46
I can't get this SELECT statement to work:

SELECT TOP 10 * FROM scope() WHERE FREETEXT(Contents, '" + searchText + "') AND NOT CONTAINS (filename,'.ascx') ORDER BY rank DESC ";

I keep getting the error:

Incorrect syntax near '10'. Expected ',', '.', FROM. SQLSTATE=42000

I've tried adding a ',' and ', ' but then I get an "Incorrect Syntax" error. Any suggestions?

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-03-07 : 14:45:55
my suggestions are:

1) when asking for help, show the entire statement you are trying to execute, in the full context. Why is there a "; at the end of this? Is this part of a C# statement? How can we help you with syntax errors when you don't show us the whole thing, or even tell us which programming language you are in.

2) more important, never try to building and concatenate sql commands like that. Always use parameters when building SQL statements, and better yet, use stored procedures and that is even easier. Read http://weblogs.sqlteam.com/jeffs/archive/2006/07/21/10728.aspx for more info on this. Doing things using best practices eliminates syntax errors, injection security issues, datatype conversions, string formatting, delimiting, and so on. Always, always use parameters when passing information from your client app to a SQL Server stored procedure or SQL statement.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

barryman9000
Starting Member

4 Posts

Posted - 2007-03-07 : 16:38:02
Jeff, I see you edited your post. Interesting. I looked at it earlier and you seemed pissed off at me like Nick Burns from SNL. Did I offend you, and now you've cooled down?

In any case, I don't want your help. I can't stand nerds who get mad at people for asking a question. It's obvious I'm a little lost, otherwise I wouldn't have asked for help. If you see a frustrating post, ignore it. If you want to help but need more info, ask for it, but don't try and attack people in a forum. That's a pretty weak move.
Go to Top of Page

barryman9000
Starting Member

4 Posts

Posted - 2007-03-07 : 16:55:11
What happened? You weren't happy with that post either? I can't show you where you attacked me, because you keep editing or erasing your posts. Over it.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-03-07 : 16:55:36
barryman9000 -- i initially posted an apology for some weird reason, assuming I wrote something to offend you. But after I re-reading my post, and then yours (where you say you can't stand nerds like me), I deleted it. Only one person here needs to do some apologizing, and it isn't me.

Good luck! And despite all that, you may even realize that I gave you some great advice if you would follow it.


- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

barryman9000
Starting Member

4 Posts

Posted - 2007-03-07 : 17:03:02
case in point. You changed your original post too.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-03-07 : 17:45:14
Yes, I edited my original post to fix a typo, and to fix the link I gave. I don't think I deleted any insults directed at you. If you recall some being there, let me know what I said and if I indeed I edited that out then of course I'll apologize. But I really don't think directed any insults at you.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -