ورود

View Full Version : سوال در مورد Select



سیروس مقصودی
سه شنبه 12 مهر 1384, 14:09 عصر
با سلام

چگونه میتوان شماره رکوردهای یک جدول پیدا کرد ؟

با تشکر

PalizeSoftware
سه شنبه 12 مهر 1384, 15:09 عصر
سلام
دوست عزیز هیچ نیازی به تکرار کردن تاپیک برای یافتن سوال نیست.
مطمئن باشید دوستان شما به سوال شما جواب می‌دهند پس هر سوال رو فقط یکبار مطرح کنید و نه بیشتر

و اما پاسخ
اگر قصد تفکیک رکوردها رو دارید، برای اینکار می‌توانید یک فیلد برای هر ردیف در نظر بگیرید که در واقع کلید اصلی جدول شما باشد. اما اگر منظور دیگری دارید بیشتر شرح بدید.
موفق باشید

Kamyar.Kimiyabeigi
سه شنبه 12 مهر 1384, 20:42 عصر
اگر قصد تفکیک رکوردها رو دارید، برای اینکار می‌توانید یک فیلد برای هر ردیف در نظر بگیرید که در واقع کلید اصلی جدول شما باشد

طبق گفته دوستمون این یک راه حله ولی اگه نمی خواین به کلید اصلیتون دست بزنین بهتره این شماره رکورد رو در برنامه استخراج کنین
با چه زبانی کار می کنین؟

Achchan
چهارشنبه 13 مهر 1384, 17:22 عصر
طبق گفته دوستمون این یک راه حله ولی اگه نمی خواین به کلید اصلیتون دست بزنین بهتره این شماره رکورد رو در برنامه استخراج کنین
با چه زبانی کار می کنین؟
Explain us why an identity column should be PK necessarily in your opinion? You have seen it so,but it is not sufficient!
Due to lack of rownum in SQL Server 2000(Maybe this is not a major problem,but SQL Server 2005 will add this ability) you can't find the row number of a row.In many cases it is not necessary too,Relational model is all about sets and there is no element order in sets.
However you can simulate this using an identity column .No need to make it PK,it will preserve uniqueness,it wont be referenced by other columns.
Another solution for preserving physical model and not changing it is to create a temp table with an identity column and pull the data into that temp table first and then perform the query.Pesonally I think this is not a good idea for large tables and specially for queries without a strong restricting where clause. Note you should drop and create such a temp table many times if your query execution frequency is high. Maybe you want to use this in stable,fixed database that the DBAs or designer don't let you to change anything within that.
-Regards and feel free to mail me: baronc_rampantc@yahoo.ca