SELECT INTO

This is a quick way to copy data from one table to the other. The other table will be created.

See example below, using the AdventureWorks2012 sample database from Microsoft

SELECT
[AddressID]       ,[AddressLine1]       ,[AddressLine2]       ,[City]       ,[StateProvinceID]       ,[PostalCode]       ,[SpatialLocation]       ,[rowguid]       ,[ModifiedDate]
into   MyList
FROM   [AdventureWorks2012].[Person].[Address]

6-5-2013 8-12-58 PM

Result (19614 row(s) affected)

Recommended Books

SQL Server Books l recommend:

  • SQL Server Execution Plans – Grant Fritchey  [Simple Talk Publishing]
  • Querying SQL Server 2012 – Ben-Gan I., Sarka D., Talmage R. – Training Kit (Exam 70-461) [Microsoft Press]
  • Pro SQL Server 2012 Integrated Services – Frances Rodrigeues [apress]
  • Professional SQL Server 2012 Internals & Troubleshooting – Bolton, Christian [John  Wiley]

 

Importing Edgar Database

We will be showing how to import database data from Edgar, with SQL code as well as SSIS Import Wizard configuration settings.

“Since 1934, the SEC has required disclosure in forms and documents. In 1984, EDGAR began collecting electronic documents to help investors get information”

First import the latest master.idx from http://www.sec.gov/edgar/indices/fullindex.htm and edit the file as shown below.

1-24-2013 5-27-40 PM 1-24-2013 5-28-05 PM

Create a database called Edgar

Create a table called master1 using T-SQL code below

Right click on Edgar database,click Tasks, then Import dat and use settings below.

 

USE [Edgar]
GO

/****** Object: Table [dbo].[master_02102013] Script Date: 2/10/2013 1:41:59 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[master_02102013](
[MasterID] [int] IDENTITY(1,1) NOT NULL,
[CIK] [varchar](50) NULL,
[Company Name] [varchar](200) NULL,
[Form Type] [varchar](50) NULL,
[Date Filed] [varchar](50) NULL,
[Filename] [varchar](50) NULL,
CONSTRAINT [PK_master_02102013] PRIMARY KEY CLUSTERED
(
[MasterID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

1-24-2013 5-56-23 PM 1-24-2013 5-55-57 PM 1-24-2013 5-55-45 PM 1-24-2013 5-55-20 PM 1-24-2013 5-54-57 PM 1-24-2013 5-53-34 PM 1-24-2013 5-57-19 PM 1-24-2013 5-57-03 PM 1-24-2013 5-56-48 PM

Make sure Identity insert is checked off. Also make sure you select delete existing rows NOT append row data.

Example Search T-SQL Query after import is completed.

SELECT TOP 100000 [MasterID]
,[CIK]
,[Company Name]
,[Form Type]
,[Date Filed]
,[Filename]
FROM [Edgar].[dbo].[master]

Result

1-24-2013 9-07-07 PM

Coming soon – a script, to extract ftp filepaths from above results and possibly a script [in python] tp download from ftp.sec.gov all the files into appropriate columns in our database, which currently houses 53,398 rows of data.

————–

Scriot for downloading ONE file, from say data in first row of table created above. Save this as test.scr

anonymous
<your email address goes in here>
cd edgar/data/1000045/
ls *.txt
get 0001193125-13-046001.txt
quit

Script for a batchfile to execute above. Save as, for example: gosec.bat

cls
ftp -s:test.scr ftp.sec.gov

 

 

Microsoft® SQL Server 2012 Feature Pack

Click here for this useful set of tools.

The Microsoft® SQL Server® 2012 Feature Pack is a collection of stand-alone packages which provide additional value for Microsoft® SQL Server® 2012.  It includes the latest versions of:

  • Tool and components for Microsoft® SQL Server® 2012.
  • Add-on providers for Microsoft® SQL Server® 2012.

An important component of this feature pack is:

Microsoft® SQL Server® 2012 Native Client

          Microsoft SQL Server Native Client (SQL Server Native Client) is a single dynamic-link library (DLL) containing both the SQL OLE DB provider and SQL ODBC driver. It contains run-time support for applications using native-code APIs (ODBC, OLE DB and ADO) to connect to Microsoft SQL Server 2005, 2008, 2008 R2, and SQL Server 2012. SQL Server Native Client should be used to create new applications or enhance existing applications that need to take advantage of new SQL Server 2012 features. This redistributable installer for SQL Server Native Client installs the client components needed during run time to take advantage of new SQL Server code name ‘Denali’ features, and optionally installs the header files needed to develop an application that uses the SQL Server Native Client API.

SQL Server Reporting Services [SSRS] 2008 Problem: Maximum request length exceeded

SQL Server Reporting Services [SSRS] 2008 Problem: Maximum request length exceeded

Error l get:

Error  : There was an exception running the extensions specified in the config file. —> Maximum request length exceeded.

Click on image below for larger version.

Solution:

Edit the file web.config, found in:

C$Program FilesMicrosoft SQL ServerMSRS10_50.RPTReporting ServicesReportServer

Change line:

<httpRuntime executionTimeout=”9000″ />

to:

<httpRuntime executionTimeout = “9000” maxRequestLength=”500000″ />

And then restart the SQL Server Reporting Services [SSRS] service.

This should fix the issue.