02 Nov 2011 @ 10:10 PM 

I was looking for a way to have all my tables have a unique GUID (Globally Unique ID) as well as a “Last Updated” column that would automatically update both on INSERT and on UPDATE.

Through a few hours of experimentation, I created the following:

CREATE TABLE dbo.testing
    (guid            uniqueidentifier    NOT NULL DEFAULT NEWID(),
     lastUpdated     datetime2(7)        NOT NULL DEFAULT GETDATE(),
     col1            nchar(10)           NULL,
     col2            nchar(10)           NULL)
GO
CREATE TRIGGER dbo.trLastUpdatedTesting
ON dbo.testing
AFTER UPDATE -- not insert!
AS
BEGIN

More »

Posted By: Bogus Exception
Last Edit: 11 Nov 2011 @ 05:20 PM

EmailPermalinkComments (0)
Tags
Categories: Events, Statistics, SysAdmin
 02 Nov 2011 @ 9:51 PM 

I am going through an exercise where I’m trying to find a way to compute stock metrics (technical indicators). What I need is a way to iterate over the rows in a database, computing each technical indicator, then putting that value into the table’s row for that date.

I found an example, and modified it to work on SQL SERVER 2008 R2. I hope you, too, find this solution extremely interesting:

DROP TABLE #google_stock
GO
create table #google_stock
(
quote_date [datetime],
open_price [decimal](6,2),
close_price [decimal](6,2),
high_price [decimal](6,2),
low_price [decimal](6,2)
)
GO

More »

Posted By: Bogus Exception
Last Edit: 02 Nov 2011 @ 10:21 PM

EmailPermalinkComments (0)
Tags
Categories: Events, Statistics

 Last 50 Posts
 Back
 Back
Change Theme...
  • Users » 50
  • Posts/Pages » 174
  • Comments » 61
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

ATCP, LLC



    No Child Pages.

Factoid



    No Child Pages.