Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2003
    Location
    São Paulo, Brasil
    Posts
    4

    Unanswered: Creating table daily

    How can I create a table daily, whose name was the current date in the yy/mm/dd format plus the algarism to identify the weekday (for example Wednesday = 4), for instance if the query was run on 01/15/2003 (wednesday), the tabelname would be 3_01_15_4 ?

  2. #2
    Join Date
    Sep 2003
    Posts
    212

    Re: Creating table daily

    Originally posted by cassianorsilva
    How can I create a table daily, whose name was the current date in the yy/mm/dd format plus the algarism to identify the weekday (for example Wednesday = 4), for instance if the query was run on 01/15/2003 (wednesday), the tabelname would be 3_01_15_4 ?

    declare @date char(9)
    set @date = substring(convert(char(4),getdate(),121),4,1)+'_'+ substring(convert(char(7),getdate(),121),6,2)+'_'+ substring(convert(char(10),getdate(),121),9,2)
    +'_'+cast(DATEPART(dw, GETDATE()) as char(1))

  3. #3
    Join Date
    Nov 2003
    Location
    São Paulo, Brasil
    Posts
    4

    Doubt

    Thank you !

    The table creation is not included on the proceedure above, right ?

  4. #4
    Join Date
    Sep 2003
    Posts
    212

    Re: Doubt

    Originally posted by cassianorsilva
    Thank you !

    The table creation is not included on the proceedure above, right ?
    No it's not, once u have the string in the @date variable, just concatenate that with ur tablename and use that string in ur table creation

    says ur final tablename is in a variable @tablename.

    exec('Create table '+@tablename)

    Sumthin around those lines

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •