Jump to content

Search the Community

Showing results for tags 'T-SQL'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 4 results

  1. If you look in the DEFINITION and USAGE paragraph, you'll see that GETDATE() is being used instead of GETUTCDATE().
  2. HelloI know this is a total newb question, but i have the following SQL: SELECT FagNavn, adgangskrav, Ugedag, holdId, fagKode, CONVERT(CHAR(10), StartDato, 105) AS startDate, CONVERT(CHAR(10), slutDato, 105) AS endDate, afdeling, link, navn, deltagerBetaling, bt, niveau, Case When Ugedag = 'Mandag' Then frakl + ' - ' + tilkl Else '' End AS startSlutMandag, Case When Ugedag = 'Tirsdag' Thenfrakl + ' - ' + tilkl Else '' End AS startSlutTirsdag, Case When Ugedag = 'Onsdag' Thenfrakl + ' - ' + tilkl Else '' End AS startSlutOnsdag, Case When Ugedag = 'Torsdag' Then frakl + ' - ' + tilkl Else '' End AS startSlutTorsdag, Case When Ugedag = 'Fredag' Thenfrakl + ' - ' + tilkl Else '' End AS startSlutFredag FROM [VisWebHoldSkema] ORDER BY afdeling This is giving me records with each weekday (Ugedag) like this: +--------+-----------------+------------------+-----------------+------------------+-----+ | holdId | startSlutMandag | startSlutTirsdag | startSlutOnsdag | startSlutTorsdag | ... |+--------+-----------------+------------------+-----------------+------------------+-----+| 1587b1 | 09:00 - 15:30 | | | | ... |+--------+-----------------+------------------+-----------------+------------------+-----+| 1587b1 | | 08:00 - 15:00 | | | ... |+--------+-----------------+------------------+-----------------+------------------+-----+| 1587b1 | | | 08:30 - 18:00 | | ... |+--------+-----------------+------------------+-----------------+------------------+-----+| 1587b1 | | | | 15:00 - 04:00 | ... |+--------+-----------------+------------------+-----------------+------------------+-----+ But i need the days to be in the same record, like this: +--------+-----------------+------------------+-----------------+------------------+-----+| holdId | startSlutMandag | startSlutTirsdag | startSlutOnsdag | startSlutTorsdag | ... |+--------+-----------------+------------------+-----------------+------------------+-----+| 1587b1 | 09:00 - 15:30 | 08:00 - 15:00 | 08:30 - 18:00 | 15:00 - 04:00 | ... |+--------+-----------------+------------------+-----------------+------------------+-----+ Some sample data from the db: Any ideas? data.txt
  3. I have created a T-SQL code, this code has created a Capacity Table for the year 2010 (See Below), what I now need it to do is repeat this for the following years 2011,2012,2013,2014 and 2015 all in the same table but I cannot figure out how to do this. This code uses other tables to provide it the results. Thanks in Advance.DECLARE @PitchType_Skey INTDECLARE @Site_Skey INTDECLARE @Capacity INTDECLARE @StartDate DATEDECLARE @EndDate DATESET @PitchType_Skey = 1SET @Site_Skey = 1SET @Capacity = 0WHILE (@Site_Skey < 127)BEGINIF @PitchType_Skey = 8BEGINSET @PitchType_Skey = 1SET @Site_Skey = @Site_Skey + 1ENDIF (@Site_Skey < 127)BEGINSet @Capacity = (SELECT SiteWeighting From Site Where Site_Skey = @Site_Skey)Set @Capacity = @Capacity * (SELECT PitchTypeWeighting From PitchType Where PitchType_Skey = @PitchType_Skey)Set @Capacity = @Capacity * ((10*(100+((RAND()*40)-20)))*0.01)INSERT INTO CapacitySELECTCASEWHEN (SELECT SiteWeighting FROM Site WHERE Site_Skey=@Site_Skey) = 1 THEN '1 May 2010'WHEN (SELECT SiteWeighting FROM Site WHERE Site_Skey=@Site_Skey)=2 THEN '1 Apr 2010'WHEN (SELECT SiteWeighting FROM Site WHERE Site_Skey=@Site_Skey)=3 THEN '1 Apr 2010'WHEN (SELECT SiteWeighting FROM Site WHERE Site_Skey=@Site_Skey)=4 THEN '1 Jan 2010'ELSE NULLEND as StartDate,CASEWHEN (SELECT SiteWeighting FROM Site WHERE Site_Skey=@Site_Skey)=1 THEN '30 Sep 2010'WHEN (SELECT SiteWeighting FROM Site WHERE Site_Skey=@Site_Skey)=2 THEN '1 Nov 2010'WHEN (SELECT SiteWeighting FROM Site WHERE Site_Skey=@Site_Skey)=3 THEN '1 Nov 2010'WHEN (SELECT SiteWeighting FROM Site WHERE Site_Skey=@Site_Skey)=4 THEN '1 Dec 2010'ELSE NULLEND,round(@Capacity,0) as Capacity,@PitchType_Skey, @Site_SkeyENDSET @PitchType_Skey = @PitchType_Skey + 1END
  4. I created a simple Stored Procedure (SP) that queries a table and renames the column names, and I'm able to push those results out to a CSV file *with* those header names when done manually.But when I try to export the results to a CSV file by running the same SP using xp_cmdshell with bcp, the header row (Col1, Col2, and Col3) does not appear in the resulting CSV file.ORIGINAL TABLE:ColumnName1-----ColumnName2-----ColumnName3Joe Schmo CustomerJane Doe CustomerTim Tiny MusicianQUERY WITHIN SP:SELECT ColumnName1 AS Col1, ColumnName2 AS Col2, ColumnName3 AS Col3FROM TABLENAMEQUERY RESULT:Col1-----Col2-----Col3 <<<<----- WHAT I WANT!Joe Schmo CustomerJane Doe CustomerTiny Tim MusicianHere's the code I'm using within the job:EXEC xp_cmdshell 'bcp "EXEC DATABASENAME.dbo.STOREDPROCEDURENAME" QUERYOUT "\\MYSERVERNAME\files\export.csv" -c -t, -T -S'CSV FILE RESULT USING BCP:Joe Schmo CustomerJane Doe CustomerTim Tiny MusicianAs you can see the headers are missing. What am I doing wrong?
×
×
  • Create New...