Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Neew T-SQL for setting date Expand / Collapse
Author
Message
Posted Monday, February 11, 2013 2:49 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, June 13, 2013 2:29 PM
Points: 101, Visits: 248
UPDATE [tblTransactions] SET [AllocatedDate] = ........
Basically I need to set AllocatedDate to "Today" using something like "Now" or "Now()"... any ideas? Thanks!
Post #1418640
Posted Monday, February 11, 2013 2:58 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 9:17 PM
Points: 21,832, Visits: 27,855
briancampbellmcad (2/11/2013)
UPDATE [tblTransactions] SET [AllocatedDate] = ........
Basically I need to set AllocatedDate to "Today" using something like "Now" or "Now()"... any ideas? Thanks!


UPDATE [tblTransactions] SET [AllocatedDate] = getdate();



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1418645
Posted Monday, February 11, 2013 6:12 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 12:22 AM
Points: 2,370, Visits: 3,250
Lynn Pettis (2/11/2013)
briancampbellmcad (2/11/2013)
UPDATE [tblTransactions] SET [AllocatedDate] = ........
Basically I need to set AllocatedDate to "Today" using something like "Now" or "Now()"... any ideas? Thanks!


UPDATE [tblTransactions] SET [AllocatedDate] = getdate();


No, no, no, no. That is not ANSI/ISO standard! Use this instead:

UPDATE [tblTransactions] SET [AllocatedDate] = CURRENT_TIMESTAMP;

Ooops! Sorry, CELKO moment there.

Actually either will work and I use GETDATE() all the time myself.



No loops! No CURSORs! No RBAR! Hoo-uh!

INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?

Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Are you too recursively challenged?
Splitting strings based on patterns can be fast!
Post #1418708
Posted Tuesday, February 12, 2013 6:22 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, June 13, 2013 2:29 PM
Points: 101, Visits: 248
Thanks! Works!
Post #1418925
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse