Need help to create file with name and current time stamp.

I need to create .xlsx file exporting data from sql database and file name would be 'FileName' and current yyyymmdd. 
I'm trying to use following code but it's keep saying  incorrect syntax near "+".
EXEC p_CreateExcel 'sql64', 'NewFile', '\\hrfile1\Shared\Buying Report\NewFile'
+ CAST(YEAR(CURRENT_TIMESTAMP) AS VARCHAR)
+ RIGHT('00'+CAST(MONTH(CURRENT_TIMESTAMP) AS VARCHAR),2)
+ RIGHT('00'+CAST(DAY(CURRENT_TIMESTAMP) AS VARCHAR),2)+'.xlsx'

This is what I have on EXEC p_CreateExcel
USE [XePro01]
GO
/****** Object:  StoredProcedure [dbo].[p_CreateExcel]    Script Date: 02/26/2015 11:27:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[p_CreateExcel]
        @db_name varchar(100),
        @table_name varchar(100), 
        @file_name varchar(100)
as
--Generate column names as a recordset
declare @columns varchar(8000), @sql varchar(8000), @data_file varchar(100)
select 
        @columns=coalesce(@columns+',','')+column_name+' as '+column_name 
from 
        information_schema.columns
where 
        table_name=@table_name
select @columns=''''''+replace(replace(@columns,' as ',''''' as '),',',',''''')
--Create a dummy file to have actual data
select @data_file=substring(@file_name,1,len(@file_name)-charindex('\',reverse(@file_name)))+'\data_file.xls'
--Generate column names in the passed EXCEL file
set @sql='exec master..xp_cmdshell ''bcp "set fmtonly off select * from (select '+@columns+') as t" queryout "'+@file_name+'" -c -t, -T -S'''
exec(@sql)
--Generate data in the dummy file
set @sql='exec master..xp_cmdshell ''bcp "set fmtonly off select * from XeProgst01.dbo.'+@table_name+'" queryout "'+@data_file+'" -c -t, -T -S'''
exec(@sql)
--Copy dummy file to passed EXCEL file
set @sql= 'exec master..xp_cmdshell ''type '+@data_file+' >> '+@file_name+''''
exec(@sql)
--Delete dummy file 
set @sql= 'exec master..xp_cmdshell ''del '+@data_file+''''
exec(@sql)
GO

Similar Messages

  • Need help in Creating a dynamic name for a file.

    I am working on FTP Put and I have a requirement where in I have to generate the file with dynamic content in its name.I dont need any time stamp.I need to create a variable for this?
    Help in this regard would be highly appreciated.

    Take a look at File tmp = File.createTempFile("aaa", ".txt");
    String name = tmp.getpath();This will create a File with a name like aaannn.txt where nnn is a system generated number guaranteed to exists only once.

  • Need help to create report with jpeg/gif image

    Hello,
    I need help with creating a form with a special jpeg/gif seal. I never done this Java. Until now, I created all forms with ansi C++ with HP escape characters to draw lines, boxs, and text. This form will contain boxes which is populated with database information read from a text file.
    Since this form contains a special seal on the upper right, I don't think it can be done with old fashion ansi C++. How can I create a form with Java and create it as a simple exe to just print the form to a specified printer.
    Thanks,
    John

    Hi,
    I am creating a form with boxes (lines and text). What is special about this form is that it has an image jpeg or gif at the top right corner. Is is a state department seal. Up to this form, I had used ansi C++ and print out escape HP character to print out the lines, boxes, and text. I have no idea how to print out the image. I am new to JAVA and only 1 class in it. Is there sample code out there to create this type of form with the image? I need a starting point.
    Thanks,
    John

  • Automator: Create folder with name and subfolders in it.

    Hello everyone, my question is related to Automator. I work in a company where we have a huge server. Every time a new job comes in it gets a six digits number and a folder with 5/6 subfolder needs to be created. The main folder will be xxxxxx_nameofbrand and will contain 5 subfolder each one of them starting with the six digit number assigned initially followed by 5 tags (always the same ones).
    Everytime it's a long thing to create it manually and copy and paste every number and name, so I thought I could use automator to do it easilly but I always get stucked at the part where I want the 5 subfolder to go in the main one. This is what I had done, but I'm pretty sure there is a faster/easier way to do it.. I'm really new to automator, I know it's potential but don't know how to use it very well..
    I thank you all for the help.

    For this kind of exception, you can just add a Run AppleScript action at the end of the workflow - for example, the following will rename all folders ending with the specified name that are at the specified depth in the structure:
    on run {input, parameters} # remove prefix from folder name
      set sourceFolder to quoted form of POSIX path of (input as text)
      set exceptionName to "Links" # will find a name ending with this (case sensitive match)
      set exceptionDepth to 2 # at a folder depth of this
      set theFolders to (do shell script "find " & sourceFolder & " -name " & quoted form of ("*" & exceptionName) & " -depth " & exceptionDepth)
      repeat with anItem in paragraphs of theFolders # rename without prefix
        tell application "System Events" to set name of folder anItem to exceptionName
      end repeat
      return input
    end run

  • Need help for Flash quiz with score and timer

    Greetings, I need to urgently create a flash
    game with 10 questions, 3 answers per question. At the end of the
    quiz I need to get the time the quiz was completed for, what answers the player answered correctly and the time its completed into a database, + a couple of fields like name and phone that the user fills also needed to be added into db with the score and time. I need it by the end of tomorrow and I do realise i dont have the knowledge to make it, So if there is anyone that wishes to help or trade services I can give you back the favour by creating some html/css/web design content for you. Thanks in advance and please excuse me for my terrible english.

    download flash cs6 and use it to publish your ad or expand flash cc's publishing capabilites.  if you have a flash cc subscription you can download and use flash cs6 after logging into your cc acount.
    here's how to expand publishing capabilites of flash cc: http://forums.adobe.com/message/5511080#5511080#5511080

  • Need help exporting ID file with TOC to EPUB.

    I've been troubleshooting a file created in ID CS5.5 and then moved to CC. When I export to EPUB the TOC ends up at the end of the file rather than at the point where I originally inserted the TOC. The vendor I'm sending the EPUB to won't accept a file with the TOC out of place. I tried exporting to an HTML editor and moving the TOC there. (I'm no whiz at HTML though.) Now I see no way to import the file back into ID to export it as EPUB ( and doubt that's the best way to deal with this anyway). I'd deeply appreciate any suggestions!

    First of all, a TOC is not only "The Toc". You need to distinguish between the dynamic Reader TOC and a optional TOC e.g. on page 3. While the first is generally required, the second is optional in most cases.
    You must also distinguish whether the export is EPUB 2 or EPUB 3.
    1. Assume you mean the dynamic TOC > InDesign will create the TOC on the right place, if you choose the TOC-Style during the export.
    2. Assume you mean the TOC on page 3 > Here the content- or article-order is important! If you have a threaded story from page 2-100 and your TOC as a single frame on page 3 > InDesign will first export the content on page 2 AND the content of all threaded frames and at least your TOC on page 3.
    3. Assume further your exported file is correct in most cases, you can change the order of your TOC in the EPUB directly in the content.opf file in the spine-area
    To give you more help, I must have a look at your file.
    Kai Rübsamen

  • Need help moving photoshop files with layers

    I have been having some trouble, when I attempt to move photoshop files with a CD-R disk, from my school pc to my home mac, only the top most image is moved. The layers are deleted, and I only receive the image on the background layer. I need the layers to continue working on the pieces. Would a flash drive transfer the whole file, or am I doing something wrong with the disk file?

    Yeah, time is a factor because the system is getting wiped in a few days. The school version is photshop 7 I believe, and I have photoshop CS3 extended here. What I did was save the file to the CD burner, I didn't change the format to my knowledge. I thought that the data would have transfered from computer to computer, but it didnt, its like it saved as a different file entirely. I assume that using a flash drive would preserve the info in its entirety. I guess your saying that the type of file its saved as changes whether its a photoshop layers file, or just a flat image. I'll try again tomorrow.

  • Need help to reduce file with photoshop!!

    I own a website flash game http://babegamer.com
    I asked someone create a banner for my site but it in GIF animation with over 1.5mb. Thus, I change it into jpg with only 30kb (static banner).
    Someone tell me convert gif to swf to reduce the size. How ever when I try to use the software to convert it, it make a swf which is bigger size then gif.
    How can I do it?

    babegamer.com wrote:
    How can I do it?
    You rebuild it in Flash! Sorry, there's no easy solution to your problem. You need to encode the stuff as FLV and then create a proper SWF from it or even better, animate everything as native layers/ symbols in Flash. Your alleged magic conversion too fails, because such tools embed each frame as a JPEG, hence such SWFs often get larger than the source. If you will - they are merely converting each frame of your GIF to a JPEG and embed it into an SWF wrapper.
    Mylenium

  • I have omf video files with start and ending time tag that I like to view on iPad

    I have a large video file in the .omf (open media format).  It is sometime called Avid video editor interchange.   I heard that Quicktime has the ability to display the omf video file ??
    I am looking for a viewer for the iPad that can view the omf file with the ability to just show the starting time stamp to the ending time stamp.
    I appreciate any help.
    Thank You

    http://support.apple.com/kb/ht5209
    http://support.apple.com/kb/ht4437
    http://support.apple.com/kb/TS4215
     Cheers, Tom
    Oops!!!!!! Just realized Airplay & Apple TV requires iPad 2 (or later).
    Message was edited by: Texas Mac Man
    But there may be a way. http://www.youtube.com/watch?annotation_id=annotation_586623&feature=iv&src_vid= urjjHjJ0pdc&v=sSKQVxucnLY

  • Needing script to move files with name that starts with

    Here is part of the script that takes a excel file for the list to duplicate files from one folder the another. I would like it to use file name starts with instead exact file name. If I can get this to work I will not have to have a try for .jpg and a seperate try for .eps
                tell application "Finder"
                    try
                        duplicate (sourceFolder & theItem & ".jpg" as string) to destFolder with replacing
                    on error
                        do shell script "echo " & theItem & ">> $HOME/Desktop/NotFound.txt"
                    end try
                    try
                        duplicate (sourceFolder & theItem & ".eps" as string) to destFolder with replacing
                    on error
                        do shell script "echo " & theItem & ">> $HOME/Desktop/NotFound.txt"
                    end try
                end tell
    Thanks

    Ok here is the script that I've been using for a couple of years now with no problems, until I upgraded. Don't know what happened, because I cant even use it on a older system that we have. The error I get is when it tries to get the value of selection from Excel. It times out with no values. Thanks for any help!
    set sourceFolder to choose folder with prompt "Select the folder that contains images to move."
    set destFolder to choose folder with prompt "Select the destination folder"
    if sourceFolder is not destFolder then my moveImageFiles(sourceFolder as string, destFolder)
    on moveImageFiles(sFolder, dFolder)
        script o
            property valuesList : {}
        end script
       tell application "Microsoft Excel" to set o's valuesList to value of the selection
        if class of o's valuesList is not list then return -- not multiple selection
        set tc to (count o's valuesList)
        set dFolder to quoted form of POSIX path of dFolder
        set errorFile to quoted form of POSIX path of (sFolder & "filesNotFound or NotMoved.txt")
        do shell script "/bin/rm " & errorFile & " > /dev/null 2>&1 &" -- remove the error file (if it exists)
        repeat with i from 1 to tc
            repeat with thisValue in (get item i of o's valuesList)
                if contents of thisValue is not "" then -- not a blank cell
                    set tFile to quoted form of POSIX path of (sFolder & thisValue)
                    try
                        do shell script "shopt -s nocaseglob; /bin/mv -f " & tFile & "* " & dFolder
                    end try
                end if
            end repeat
        end repeat   
        do shell script "/usr/bin/open -b com.apple.textedit " & errorFile & " > /dev/null 2>&1 &"
    end moveImageFiles

  • Need help setting up JDBC with mySQL and Netbeans

    I've successfully got mySQL up and running and created a few simple test databases. I've been following the instructions on this website (http://www.stardeveloper.com/articles/display.html?article=2003090401&page=1 ) to get JDBC working but have had little luck.
    I've downloaded JDBC from mySQL website, extracted the mysql-connector-java-3.1.13-bin.jar file and changed the class path to :
    C:\Program Files\Java\jre1.5.0_06\lib\ext\mysql-connector-java-3.1.13-bin
    which is where I placed the .jar file.
    I then used the following code provided on stardeveloper.com to test a connection with the test database.
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class JdbcExample2 {
      public static void main(String args[]) {
        Connection con = null;
        try {
          Class.forName("com.mysql.jdbc.Driver").newInstance();
          con = DriverManager.getConnection("jdbc:mysql:///test",
            "root", "secret");
          if(!con.isClosed())
            System.out.println("Successfully connected to " +
              "MySQL server using TCP/IP...");
        } catch(Exception e) {
          System.err.println("Exception: " + e.getMessage());
        } finally {
          try {
            if(con != null)
              con.close();
          } catch(SQLException e) {}
    }It compiles but when run I get the error message :
    java.lang.NoClassDefFoundError: testdatabase/JdbcExample2
    Exception in thread "main"I assume this means that my classpath isn't setup correctly but I have no idea what's up and how to correct it.
    Can someone PLEASE tell me how to setup jdbc and what I've done wrong.
    Thanks in advance :)

    Thanks for your reply. I've made some progress but I'm still having problems.
    In mySQL I created a new user called uraknai with password n0121429 and granted them access to a test database I created called pet.
    Then, in netbeans, I clicked the Runtime tab, clicked Databases and rightclicked Drivers and clicked Add Driver. I then added the driver mysql-connector-java-3.1.13-bin.jar. I then right clicked the newly added driver and selected the connect using option. I filled in the appropriate boxes clicked ok and it connected successfully.
    Then, under the project tab, I right clicked the project name, clicked properties then clicked Libraries and added the .jar file mysql-connector-java-3.1.13-bin.jar
    I then ran the following code to test the connection to the database:
    import java.sql.*;
    public class ConnectionTest {
        public ConnectionTest() {
        public static void main(String[] args)
            System.out.println("BEGIN CONNECTION TEST");
            Connection conn = null;
            try
                   String userName = "uraknai";
                   String password = "n0121429";
                   String url = "jdbc:mysql://localhost/pet";
                   Class.forName ("com.mysql.jdbc.Driver").newInstance ();
                   conn = DriverManager.getConnection (url, userName, password);
                   System.out.println ("Database connection established");
             catch (Exception e)
                   System.err.println ("Cannot connect to database server");
             finally
                   if (conn != null)
                       try
                           conn.close ();
                           System.out.println ("Database connection terminated");
                       catch (Exception e) { /* ignore close errors */ }
    }and get the message:
    java.lang.NoClassDefFoundError: math/ConnectionTest
    Exception in thread "main"
    Java Result: 1when I run the code.
    Can someone explin what I've done wrong and how to fix the problem.
    Cheers.

  • Need help deploying batch file to WINXP and WIN7 computers

    Hello all and thanks for your time and expertise.
    I'm trying to deploy a batch file to unregister vgx.dll in response to the zero day flaw.  Symantec provided the batch file and it works but now I have to get it deployed.  I was trying to use Group Policy Preferences/Scheduled Tasks and Immediate
    Task for both a WINXP deployment and a WIN7 Deployment.  There are immediate task options for XP and WIN7.
    I have the vgx.bat file at c:\ of my DC.  The rest of the settings are as follows:
    RUN:  c:\vgx.bat
    Arguments:  blank
    Start in: blank
    And then Item Level targeting is set to deploy to Windows XP and Windows 7 respectively.  I'm deploying tasks to the respective operating systems in the same GPO.
    On my test systems - the GPO say it was applied but vgx.dll is still showing in the registry.  Basically once you unregister this file it won't show in the registry under HKEY_CLASSES_ROOT subkey CLSID. I tested this on another system manually. Additionally
    I get no error message in event viewer.
    Anyway, your help and recommendation on this matter would be greatly appreciated.

    Hello Pendal,
    Actually I deployed the workaround for this vulnerability yesterday via batch file and it was successful. What I did was to create a batch file and apply it as
    start up script since it is unlikely for vgx.dll to become unregistered using logon script.
    "%SystemRoot%\System32\regsvr32.exe" -u "%CommonProgramFiles%\Microsoft Shared\VGX\vgx.dll"
    There are other options for you to patch these Zeroday including preventing Active-X and Active Script to run using GPO. Another option would be to Deny access to the mentioned dll file.
    Regards.
    Mahdi Tehrani   |  
      |  
    www.mahditehrani.ir
    Please click on Propose As Answer or to mark this post as
    and helpful for other people.
    This posting is provided AS-IS with no warranties, and confers no rights.
    How to query members of 'Local Administrators' group in all computers?

  • Newbie needs help on creating banner with vanishing text.

    I have never used Flash before.  I may even be barking up the wrong tree. I am trying to create a banner that has text that "appears" and then "disappears". This is the mockup I made for the banner.  I would like for the sentences to seem like they are coming out of the couds, and then vanishing. Any help you can offer would be greatly appreciated!
    Thanks in advance,
    Margaret

    Thanks Ned!  I did what you said and now have the words animated like I need to.  But I am still having one problem.  I'm not sure how to get my background to be visible through the entire animation.  I can see it in the first frame and then it disappears.
    Thanks again,
    m

  • (need help) Replacing AVI files with MOV files in a edit.

    I'm working on a large edit that uses low res AVI files for editing,
    Though all the high res files are written as MOV's with exactly the same name (just being a different filetype)
    Is there a way to automaticly re-link all those avi movies with those high res MOV files?
    The edit is quite big, so it would save me a very tedious job

    Close Premiere.  Change the name of the folder the current AVI files are in.  Reopen Premiere.  When it asks you where the files are, point it to the new ones.
    The only stumbling block may be the different extension.  I'm not sure if Premiere will pass that by or trip over it.

  • Hi I need help in creating role for DEVELOPERS and HCM GUYS in ERP DEV. sys

    Hi Experts
    I am working as a Support Security Consultant. Now I have assigned to another implemenation Project.
    My client asks to create 2 roles in DEV. system the requirement is:
    1) He asks to create a role for develpoers in dev system fro devepment activities ( report creation, screen creation..etc..) and these people don't modify the HR related tables
    2) He asks to create role for HCM guys in development system to work on HCM Configuration and to work on HCM areas but these people should not involve into develpometn activites
    My questions is what are the tcodes we have to maintain in the roles to reach his requirement.
    I asked the same thing to my Client he doesn' t provide any information
    Please anyone help me on this
    Thanks
    Naresh

    Hi,
    for the first query please check auth object -Authorization Object S_TABU_DIS (Table Maintenance)
    http://help.sap.com/saphelp_nw04s/helpdata/en/1e/e867408cd59b0ae10000000a155106/content.htm
    No Worries
    KG

Maybe you are looking for