Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 current year

Author  Topic 

samhrishi
Starting Member

13 Posts

Posted - 2010-11-25 : 02:35:48
Insert query for inserting current year Only into database
uson vb.net and sqlserver
tahnks

sam

Devart
Posting Yak Master

102 Posts

Posted - 2010-11-25 : 03:05:23
Hello,

For exmaple:

CREATE table t_year(
id_year int);

GO

INSERT INTO t_year (id_year)
SELECT year(getdate());

go

select * FROM dbo.t_year;

Best regards,

Devart,
SQL Server Tools:
dbForge Schema Compare
dbForge Data Compare
dbForge Query Builder
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-11-25 : 03:22:16
INSERT dbo.TargetTable (Column set here...)
SELECT (Column set here...)
FROM dbo.SourceTable
WHERE SomeDateTimeColumnHere >= DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()), 0)
AND SomeDateTimeColumnHere < DATEADD(YEAR, DATEDIFF(YEAR, -1, GETDATE()), 0)




N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-11-26 : 02:44:08
If the above solution is not what you want, post some sample data with expected result

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

samhrishi
Starting Member

13 Posts

Posted - 2010-11-26 : 04:15:43
thaks Dev

sam
Go to Top of Page
   

- Advertisement -