Author |
Topic |
homer_dog
Starting Member
4 Posts |
Posted - 2007-10-18 : 06:32:52
|
Hey All,I am new to programming in SQL developer and I was hoping one of you kind salmon of knowledge could help me I am running an SQL script every 15 minutes to pull data. I would like to insert the results into a column in a table. I have two issues:1.How can I give the result column the current time stamp as an alias?2.How can I add this column to the results table (I know its Alter table but do I put this into the insert sql?)I would appreciate any help possibleThanks |
|
Kristen
Test
22859 Posts |
Posted - 2007-10-18 : 06:35:12
|
1 SELECT GetDate() AS [Now]2:INSERT INTO MyTable(NowColumn, Col1, Col2, ...)SELECT GetDate(), Col1, Col2, ...FROM MyOtherTableKristen |
|
|
homer_dog
Starting Member
4 Posts |
Posted - 2007-10-18 : 06:38:23
|
Thanks for your help i will try this code shortly |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-10-18 : 06:38:29
|
I guess you are right Kristen but it sounds like he wantsSELECT Value AS [2007-10-18]FROM Table1 E 12°55'05.25"N 56°04'39.16" |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-10-18 : 06:40:17
|
Well I've reread it and it reads your way for point 1, and my way for point 2.Time will tell, I expect! |
|
|
homer_dog
Starting Member
4 Posts |
Posted - 2007-10-18 : 06:48:18
|
Sorry I’m confusedHere is my code SELECT Operation, sum(QTY)as[This is where I would like the time stamp]FROM tblActualWIPWhere datediff(day,[Date Entered Op],getdate())<4group by OperationDo I need to declare my column alias as a variable at the top iedeclare @Now datetimeselect @Now = (select getdate())select sum(QTY) as @dateI think I'm nearly there |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-10-18 : 06:51:23
|
I guess you later want to add a column very 15 minutes to your target table?And then upsert the new column?Bad design. Don't quit your day job.It is better as Kristen suggests. Have a column for Now and then you can present the dataCROSSTAB/PIVOT style later if you want to.Don't mix up presentation layout with table design.See http://www.datamodel.org/NormalizationRules.html E 12°55'05.25"N 56°04'39.16" |
|
|
homer_dog
Starting Member
4 Posts |
Posted - 2007-10-18 : 06:54:39
|
Thank you both for your help |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-10-18 : 07:00:19
|
quote: Originally posted by homer_dog Sorry I’m confusedHere is my code SELECT Operation, sum(QTY)as[This is where I would like the time stamp]FROM tblActualWIPWhere datediff(day,[Date Entered Op],getdate())<4group by OperationDo I need to declare my column alias as a variable at the top iedeclare @Now datetimeselect @Now = (select getdate())select sum(QTY) as @dateI think I'm nearly there
Where do you want to show data?If you want to show in the front end, can you just get date and then display it?orthink if you need the code like this really?declare @Now datetime, @sql varchar(8000)select @Now = (select getdate())set @sql='select sum(1) as ['+cast(@now as varchar(30))+']'exec(@sql)MadhivananFailing to plan is Planning to fail |
|
|
Evangelinevtw
Starting Member
1 Post |
Posted - 2012-12-26 : 01:13:33
|
robert g allen books avatar game boy shaved ice machines cross pen roboticarm robotica pharmacy technician certification practice exam pet mice buy convertible battery chargers aa [url=http://www.coachbagjpn.com/]?????[/url]sony icf c212 lib hcn4226w secretos de belleza snoot scuba regulators pccard baby's crib divorce your parents natural cures for depression [url=http://www.pradaoutlettokyo.com/]??? ??[/url]organix pet food welding secrets intranet service learning acer monitor 19 [url=http://www.coachbagrakuten.com/]????????[/url] primo eurobath motorola h700 headset bath beads sharp cash registers pentax af 500 ftz |
|
|
gtopawb
Starting Member
5 Posts |
Posted - 2012-12-27 : 02:15:53
|
unspammed |
|
|
|