Today I had a requirement to save the results of an SQL query into a sql table. Usually it is easy to export to excel by using the option of copying the results and pasting them to an excel file.
But this time I had over a million rows and I didnot want to use excel to store that huge amount of data. So I followed the following 2 simple steps.
1. Create a new table in a new database:
Use the SSMS to create the database and use the create table query to create the new table as follows:
create table databasename.dbo.tablename
([col1] [varchar(20)], [col2] [int], [col3] [datetime])
2. Create a SQL query using the Insert into command as follows:
Insert into databasename.dbo.tablename
(col1, col2, col3)
select a.col1, b.col2, c.col3 from tab1 a, tab2 b, tab3 c
where a.col1=b.col1 and b.col2=c.col3 and col1='zzz'
This query has inserted data into the new table directly.
Wednesday, September 14, 2011
Thursday, September 08, 2011
Add months to date in excell
Yesterday I had this requirement to add number of months (m) to a cell that contains start date to estimate the end date. In 2003 I had to use a complex formula like below where A1 is the cell that contians the start date.
=DATE(YEAR(A1),MONTH(A1)+m,DAY(A1))
Well in Excel 2007 it is even more easy to add months with the Edate function like below.
=Edate(A1, m).
=DATE(YEAR(A1),MONTH(A1)+m,DAY(A1))
Well in Excel 2007 it is even more easy to add months with the Edate function like below.
=Edate(A1, m).
Subscribe to:
Posts (Atom)
Free Power BI Classes for Week 7 (Last)
Just completed the last class of the F ree P ower BI classes of this series. Today we have covered Adding a canvas background Adding Imag...
-
From the past 3 days I have been working on resolving merged and hidden cells issues when an SSRS reports is exported to excel. ...
-
When I tried to access the report manager after a fresh installation of Sql Server Reporting Serivces 2016 using the url http://localhost/R...
-
I was trying to build an SSIS package that one of my colleagues has created. The first error that was thrown was as below: Exception des...