April 9, 2015 at 10:10 am
Sometimes I want to quickly to edit a record in a table instead of using an insert statement.
Sometimes there are auditing columns like DateCreated, and CreatedBy,
I know it can be made as default. for DateCreated to be sysdatetime, and createdby to be system user.
But I just curious to know if there is a way to manually enter today's date and the user in the cell?
Thanks,
April 9, 2015 at 10:18 am
As long as the columns just have DEFAULTs assigned, you can treat them as any other column.
April 9, 2015 at 10:20 am
Thanks, if no default set, there is really no way to enter a function or something in the cell to get today's date, but just manually type one digit by digit of the date and time, correct?
Thanks,
April 9, 2015 at 10:47 am
Why not use GETDATE, or better still, GETUTCDATE, to retrieve the date and time you're doing your edits. You don't need to manually modify a value.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 9, 2015 at 10:52 am
Do you mean manually enter getdate(), and hit tab, it will show the datetime, that does not work for me, it says invalid value for cell.
This table has no default set, and I don't want to change that now.
But just curious if there is a way to do it when editing the cell.
April 9, 2015 at 10:57 am
sqlfriends (4/9/2015)
Do you mean manually enter getdate(), and hit tab, it will show the datetime, that does not work for me, it says invalid value for cell.This table has no default set, and I don't want to change that now.
But just curious if there is a way to do it when editing the cell.
Cell?
You mean you're using the SELECT TOP 200 or whatever and manually editing through the GUI?
I never do that.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 9, 2015 at 11:00 am
Yes, I rarely do that too, but if it is a very simple change, I do that to save time.
Just curious if SQL server have ability to do that - to enter a function in a cell to get today's date.
It looks it doesnot.
April 9, 2015 at 12:07 pm
sqlfriends (4/9/2015)
Yes, I rarely do that too, but if it is a very simple change, I do that to save time.Just curious if SQL server have ability to do that - to enter a function in a cell to get today's date.
It looks it doesnot.
I don't think so. But that's why I pretty much always use an UPDATE command. Oh, and, if I'm on production or anywhere else important, I wrap it in a transaction with the commit commented out so I can verify the correct number of rows was affected prior to me committing it. I pretty much assume I'm the most dangerous person around the database and treat myself accordingly.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 9, 2015 at 12:40 pm
sqlfriends (4/9/2015)
Yes, I rarely do that too, but if it is a very simple change, I do that to save time.Just curious if SQL server have ability to do that - to enter a function in a cell to get today's date.
It looks it doesnot.
If it is a super simple change it would be faster to just type the update instead of talking your hands off the keyboard, find the table in the tree, right click and hit edit top 200. If it isn't faster to type in an update statement you need to start typing them more so it becomes faster. 😉
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 9, 2015 at 3:32 pm
Sean Lange (4/9/2015)
sqlfriends (4/9/2015)
Yes, I rarely do that too, but if it is a very simple change, I do that to save time.Just curious if SQL server have ability to do that - to enter a function in a cell to get today's date.
It looks it doesnot.
If it is a super simple change it would be faster to just type the update instead of talking your hands off the keyboard, find the table in the tree, right click and hit edit top 200. If it isn't faster to type in an update statement you need to start typing them more so it becomes faster. 😉
although, I admit to cheating, I use SQL Prompt which makes this even faster.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 10, 2015 at 7:47 am
Grant Fritchey (4/9/2015)
Sean Lange (4/9/2015)
sqlfriends (4/9/2015)
Yes, I rarely do that too, but if it is a very simple change, I do that to save time.Just curious if SQL server have ability to do that - to enter a function in a cell to get today's date.
It looks it doesnot.
If it is a super simple change it would be faster to just type the update instead of talking your hands off the keyboard, find the table in the tree, right click and hit edit top 200. If it isn't faster to type in an update statement you need to start typing them more so it becomes faster. 😉
although, I admit to cheating, I use SQL Prompt which makes this even faster.
That isn't cheating. It is working smarter. 😉
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 11 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply