Home arrow SQL Server arrow Page 2 - SQL Sever: Storing Code in Binary or Text Files Rather than Stored Procedures
SQL SERVER

SQL Sever: Storing Code in Binary or Text Files Rather than Stored Procedures


Learn how to extend SQL Server's capabilities by making use of binary and text files, to execute SQL queries, in place of Stored Procedures.

Author Info:
By: Raghavendra Narayana
Rating: 4 stars4 stars4 stars4 stars4 stars / 33
October 21, 2003
TABLE OF CONTENTS:
  1. · SQL Sever: Storing Code in Binary or Text Files Rather than Stored Procedures
  2. · Case 1: .INI File
  3. · Case 2: SQL Query
  4. · Case 3: Complete Stored Procedure in a Binary File
  5. · Conclusion

print this article
SEARCH DEVARTICLES

SQL Sever: Storing Code in Binary or Text Files Rather than Stored Procedures - Case 1: .INI File
(Page 2 of 5 )

An SQL Server job is scheduled to run on a daily basis at 11:30 PM.  The job will execute one Stored Procedure to produce an Excel file by querying table(s).  The report is an analysis report based on Department(s).  A user wants data of different department(s) during different weeks/months/quarters in the year.  The “Department” is the only input required for the Report; there is no GUI involved.  The user has access to one .INI file where he could add/change the department names.  The SP reads the .INI file stored in a shared folder, and generates the report based on the departments stored within the file.

Dept.ini contains two departments: BPO and DEVELOPMENT.  So the report will be on these departments.

CREATE PROCEDURE DBO.CASE1
AS
BEGIN
 --Procedure to generate Profit & Loss report
 --DECLARATION SECTION

 --OTHER SQL STATEMENTS
 
 --Temporary table for getting Department Name
 CREATE TABLE #tmpDept (Dept_Name VARCHAR(20)) 

 --Gets the data from .ini file to Temp table
 BULK INSERT #tmpDept
    FROM '\\computer1\Thomson_Financial\dept.ini'
    WITH (ROWTERMINATOR = '\n')

 --Get some summary data from a view
 SELECT dept_ID, dept_TurnOver, dept_Profit, dept_Loss
FROM vw_DeptSummary
 WHERE dept_ID IN (SELECT DEPT_ID FROM DBO.DEPARTMENT
    WHERE DEPT_NAME IN (SELECT C1 FROM #TMP))

 --OTHER SQL STATEMENTS
END


blog comments powered by Disqus
SQL SERVER ARTICLES

- Executing SQL Server Stored Procedure from P...
- How to Search for Date and Time Values Using...
- Replication: SQL Server 2000 - Part 2
- Replication: SQL Server 2000 - Part 1
- SQL Sever: Storing Code in Binary or Text Fi...
- Execute SQL on Multiple Tables/Columns - New...
- How to Connect to a SQL Server from Visual F...
- SQL Server Hardware Tuning and Performance M...
- Primary Key on Multiple Tables – New RDBMS C...
- Migrating from Sybase to SQL Server
- What's Best for DBAs? GUI or T-SQL Comma...
- How to Perform a SQL Server Performance Audit
- An Introduction To The Bulk Copy Utility
- SQL Server Stored Procedures 101
- Building Your First SQL Server 2000 Database

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials