Forum Replies Created

Viewing 15 posts - 1,636 through 1,650 (of 3,543 total)

  • RE: Elegant solution to query of DATETIME data?

    Create a calendar table containing one [date] per day indexed on [Date]

    Join this table to the one specified (where [date] between Start and End dates)

    GROUP BY [date] HAVING COUNT(*) =...

  • RE: Query problem, showing missing values

    The problem is the WHERE statement, it changes the LEFT JOIN to an INNER JOIN (there are several posts on this forum that details why)

    Change the WHERE to an AND...

  • RE: Query for Flat name and Address

    The result of the pivot without GROUPING will produce the following

    IDNameAddress1Address2Address3
    1Joe Smith400 Main St  
    1Joe Smith Apt 4 
    1Joe Smith  Anywhere, US 40404
    2Bob Jones777 Maple Ln.  
    2Bob Jones Boston, MA ostalCode w:st="on">01201ostalCode> 

    To reduce this to one line per ID we can GROUP on ID and Name but we require...

  • RE: count problem - ???

    Or

    SELECT coursegroup,COUNT(DISTINCT npp) AS [NoOfIPTS]

    FROM dbo.Course

    GROUP BY coursegroup

  • RE: Query for Flat name and Address

    SELECT n.[ID],n.[Name],

    MAX(CASE WHEN a.SeqNo = 1 THEN a.AddressField ELSE '' END) AS [Address1],

    MAX(CASE WHEN a.SeqNo = 2 THEN a.AddressField ELSE '' END) AS [Address2],

    MAX(CASE WHEN a.SeqNo =...

  • RE: xcopy syntax error

    If the job step is type 'Transact-SQL Script (TSQL)', as in your case, and uses xp_cmdshell then the command will be run by SQL Server and SQL Server will need to...

  • RE: Dynamic SQL BCP

    For the query in bcp, I do not know and cannot find any documentation that states a limit.

    For EXEC the limit is the variable and therefore varchar(8000) for SQL2K. However...

  • RE: xcopy syntax error

    Only two things I can think of then

    First, and most probable, your SQL Server is running under the 'Local System Account' instead of a Domain account. The Local System Account cannot...

  • RE: xcopy syntax error

    ah! 

    Just spotted something, you have a space in the output directory, you will need to put quotes around that as well

    exec xp_cmdshell N'xcopy...

  • RE: Date uk to us

    Changing the database will make no difference if, as you should be, storing the dates as datetime.

    The way the date is read dd/mm/yyyy or mm/dd/yyyy is dependant on the language...

  • RE: excel

    If the data is as suggested by the others, ie each database row = 4 rows in spreadsheet and the 1st row = header then you will find it difficult...

  • RE: Dynamic SQL BCP

    Try

    declare @cmd varchar(4000), @sql varchar(100)

    set @sql = 'select * from sysobjects'

    set @cmd = 'master..xp_cmdshell ''bcp "' + @sql + '" queryout c:\test.csv -n -S (LOCAL) -e '''

    exec...

  • RE: xcopy syntax error

    Doh!! XCOPY errors are redirected to STDERR and wont appear in the job.txt file

    Set the Job Step to log output and check the...

  • RE: xcopy syntax error

    Probably access permissions, 2 thing to try

    1. Change job step to log information to a file and check the file

    2. change the command to

    exec xp_cmdshell N'xcopy /Y "D:\Program Files\Microsoft SQL...

  • RE: xcopy syntax error

    By default XCOPY will prompt to overwrite files and since prompts cannot be resolved in xp_cmdshell without using TYPE and redirector/pipe, I suspect that is why 'nothing happens'

    Try adding /Y...

Viewing 15 posts - 1,636 through 1,650 (of 3,543 total)