• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 429
  • Last Modified:

Incorrect syntax near '/'

Having trouble with this sql

Set @Sql = 'Select Top ' + CAST(@T as varchar) + ' columns
From table
Where PageName = ' + @ScriptName + ' '

@ScriptName is the page currently on which may be "/account/index.cfm"
I get the error "Incorrect syntax near '/' "

thanks
0
dgrafx
Asked:
dgrafx
1 Solution
 
Patrick MatthewsCommented:
Set @Sql = 'Select Top ' + CAST(@T as varchar) + ' columns
From table
Where PageName = ''' + @ScriptName + ''' '

0
 
Aneesh RetnakaranDatabase AdministratorCommented:
Set @Sql = 'Select Top ' + CAST(@T as varchar) + ' columns
From table
Where PageName = ''' + @ScriptName + ''''
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what version of SQL Server are you using?
I ask, because with SQL 2005, you don't need the dynamic sql for the SELECT TOP @T  ... stuff...
0
 
dgrafxAuthor Commented:
Thanks a lot
angel - thats really interesting
hope to move from 2000 to 2005 soon (I mean it's 2007!)
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now