Select Top @Variable * from table error
This is a common query we can see over the net. I am posting this just because today I saw this query again in DotnetSpider.
This is because of simple mistake in the query and can be rectified by just adding braces around the variable.
If you execute below code you will get an error "Incorrect syntax near '@topNum'."
declare @topNum as int
set @topNum = 10
select top @topNum * from Person.Contact
Just change above query like below and see the output!!!
declare @topNum as int
set @topNum = 10
select top (@topNum) * from Person.Contact