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

editing recrods in SQL Server database

Hi,

I am using the following SQL statement in Sql Server Management Studio to retrieve the top 5 records. However, the statement displays the records but does not allow me to edit any of them.

select top (8)dDate,nName,tType from Main;

My question is how do I modify the above statement to be able to edit any of the records displayed. Thanks
0
adamtrask
Asked:
adamtrask
  • 2
  • 2
1 Solution
 
Muhammad WasifCommented:
I never used SQL Server, you may need to include primary key too (also try *) to be able to edit the record. Editor must have a unique identifier to each row to update it.
0
 
adamtraskAuthor Commented:
Even when I include the primary key column as in the following statement the records displayed are read only. I am not allowed to edit any of the columns.

SELECT    TOP (10) ID, dDate, tTime, nNAMe, sSubject, tType, mMonth, Remarks
FROM  Main1
0
 
Muhammad WasifCommented:
A solution is already posted here

If you want to change the Edit Top <n>, go to Tools -> options, select the SQL Server Object Explorer -> Commands and it is in there.

But I would still do an update the way Rob says as it's much easier than manually editing and you are less likely to have moments of human error.
0
 
adamtraskAuthor Commented:
Thank. I get it now.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

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