Showing posts with label advise. Show all posts
Showing posts with label advise. Show all posts

Friday, February 24, 2012

Add date to record in SQL server each time record is added

Hi

Can anyone advise me as to how I can add the date and time to 2 columns in the sql server database for each record that is added. I'd prefer not to use the webform. Can sql server add the date automatically to the row?

thanks

Sure, you can do it a number of ways. Add a datetime field to your table, and set it's default value to either GetDate() or GetUTCDate(). That's one approach, but it only works for inserts.

If you want to have it updated on every update, then you will need to implement that in a trigger, or modify your UPDATE statements to set the field to GetDate() or GetUTCDate().

|||

Cool, I'll try that.

I want it INSERTED once for every record so i think the first way is the way to go.

Tell me this: do i need to add any code to the web form or is it enough to add the field to the db table and set the values?

Thanks!!

|||if you add a datetime column to a table, and set it's default value to getdate(), then whenever you insert a row into that table, the new column will have the date and time that the row was inserted. You don't have to change any SQL Statements at all, unless you've specifically created a dynamic update statement that will now attempt to insert a value into the new column, or something similiar. In most cases (I'll guess 95%+) nothing needs be changed at all.|||Cool. That is just perfect. No change needed at all. Thanks for your help!!|||I tried using the getdate() as the default; however, the date always comes out to be 1/1/1900. Any advise?|||

Haywire:

I tried using the getdate() as the default; however, the date always comes out to be 1/1/1900. Any advise?


What's the data type of the column? It should be be datetime.

Sunday, February 12, 2012

AD - SQL Service account - local or not?

Hi All,
I am looking for 'Best Practice' advise on how SQL Service accounts should b
e set up in an environment that contains many SQL 2000 Servers in an Active
Directory environment.
Is it a better practice to have the SQL Service (and SQL Agent services) run
off of Locally defined accounts (accounts defined on the SQL Server box its
elf) or AD/domain accounts? I can see how it would be a better security pol
icy to have each SQL Server
have locally defined service accounts as opposed to running off of domain/AD
accounts, but I am looking to see if there are any Best Practices advise on
this.If you do not need to access other servers on the network (like an exchange
server) then use a local account or the local system
Ray Higdon MCSE, MCDBA, CCNA
--
"DBA" <anonymous@.discussions.microsoft.com> wrote in message
news:92EC3F12-05F0-402A-8F93-01AC6113F7D6@.microsoft.com...
> Hi All,
> I am looking for 'Best Practice' advise on how SQL Service accounts should
be set up in an environment that contains many SQL 2000 Servers in an Active
Directory environment.
> Is it a better practice to have the SQL Service (and SQL Agent services)
run off of Locally defined accounts (accounts defined on the SQL Server box
itself) or AD/domain accounts? I can see how it would be a better security
policy to have each SQL Server have locally defined service accounts as
opposed to running off of domain/AD accounts, but I am looking to see if
there are any Best Practices advise on this.
>
>|||Also, if you are using virtual SQL Servers the startup account has to be
domain account.
Rand
This posting is provided "as is" with no warranties and confers no rights.|||Microsoft SQL Server 2000 SP3 Security Features and Best Practices
http://www.microsoft.com/technet/pr...n/sp3sec00.mspx
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.