Solved

Use string as SSRS table name

Posted on 2012-12-28
6
399 Views
Last Modified: 2013-01-02
I have a data source that is a folder filled with daily txt files.  Everyday I want to be able to automatically read yesterday's file.  In Report Services if I use the following code I am able to see the contents of a file.  
SELECT        *
FROM            12272012.txt

In SSMS if I use this code...
SELECT replace(convert(varchar, DATEADD(d, -1,getdate()), 101), '/', '') + '.txt' as ErrLog

It produces the file name I need (Ex: 12272012.txt) but it doesn't work in the FROM statement of SSRS.   Please help me with how I need to change this to make it work in SSRS?
SELECT *
FROM replace(convert(varchar, DATEADD(d, -1,getdate()), 101), '/', '') + '.txt'
0
Comment
Question by:BobRosas
  • 3
  • 2
6 Comments
 
LVL 8

Assisted Solution

by:venk_r
venk_r earned 150 total points
ID: 38729183
try using a stored procedure instead

 CREATE PROCEDURE myDynamic

AS

DECLARE @SQL NVARCHAR(4000)
DECLARE @table NVARCHAR(100)
SET @table =replace(convert(varchar, DATEADD(d, -1,getdate()), 101), '/', '') + '.txt'

SET @SQL='SELECT * FROM '+@Table

EXEC(@SQL)
0
 

Author Comment

by:BobRosas
ID: 38733423
Thank you for your help but if I do that I'm not sure how to access the sp.  Currently the data I need to access is a text file so my DataSource is an ODBC connection.  I don't know how to use my ODBC Data source connection and then connect to the sp.  Should I be doing this an entirely different way?
0
 
LVL 27

Expert Comment

by:planocz
ID: 38734594
One thing you may want to look at; is made your txt files into XML (layout) file.
since SSRS are just readable XML files.
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

Author Comment

by:BobRosas
ID: 38737875
Thank you for your input!  Is there a place I can go to read more about how to do this?  Or can you provide me with more details?  I would still need to be able to automatically update the txt file to an xml file and I don't know how to do that.
0
 
LVL 27

Accepted Solution

by:
planocz earned 150 total points
ID: 38737940
you  will need to most likely do it in VB or C# coding. Their is a standard import file from the framework that has all the info to make and read a XML file. It  would be too much detail work to post here. you may want to get a code book or look online to "How to create and read XML files".
0
 

Author Comment

by:BobRosas
ID: 38738465
I've increased points so I can award to both since I'm not sure how I will proceed.  Thank you for your help!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to get time difference in minutes and seconds only between 2 dates 2 41
Extract string portion 2 24
SQL Insert parts by customer 12 32
performance query 4 21
A recent questions about how to add SSRS named instances, couldn't find any that talks about SQL server 2008, anyway I decided to help by creating some screen shots. The installation is straightforward, you just pop the SQL server 2008 installati…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question