Join 132,685 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,250 people online right now. Registration is fast and FREE... Join Now!
I have a Table of countries (238 + Please Select Country) what i need is to be able to get the index of the Please Select Country using a select statement in C#. i've tried getting row num:
CODE
SELECT ROW_NUM() FROM dbo.TableName WHERE Country_Code = '0';// 0 is the value set for Please_Select_Country)
If CountryCode is an INT data type there is no need for the single quotes
sql
SELECT ROW_NUM FROM dbo.TableName WHERE Country_Code = 0
ahh, see i knew i was at least on the right track. All the examples i saw of ROW_NUM had it like i do. I'll fix it tomorrow when i get back to work. Thanks guys
No problem glad we could help. Now tell all your friends about us or I will stalk you until you do
lol well i tell everyone I'm able to. You guys are like my super secret Code ninjas.
now its coming back and yelling at me saying that ROW_NUM is not a valid colum name....... wonder if this is a SQL Server issue
to combat this i just created a PK column named ROW_NUM. Now its wierd that websites would say that you can use ROW_NUM to get the index number of an item in a database, but when used it shot back at me saying it wasn't a valid column name.
This post has been edited by rgfirefly24: 28 May, 2008 - 07:38 AM
You're getting that error because that table doesn't contain a column named ROW_NUM
aye, see edit above , From what i've read though ROW_NUM() is a t-SQL or SQL function that returns an int value from 0-infinate based on what row it found the data in the WHERE clause.
aye, see edit above , From what i've read though ROW_NUM() is a t-SQL or SQL function that returns an int value from 0-infinate based on what row it found the data in the WHERE clause.
Which version of Sql Sever are you using?
This is only available in 2005 and later versions.