Forum Replies Created

Viewing 15 posts - 361 through 375 (of 496 total)

  • RE: Create a date table

    Here is a version using a static Date table (I create and populate it with a CTE, but it is static):

    create table DateTable (DateVal datetime)

    declare @StartDate DateTime,

    ...

  • RE: Create a date table

    This is your CTE based query:

    CREATE TABLE DateRange (Id TINYINT, Start_Range DATETIME, End_Range DATETIME)

    INSERT DateRange

    VALUES (1, '2011-07-13 12:05:12.123','2011-09-15 11:00:01.234')

    ,(2,'2011-09-15 11:00:01.234','2013-10-04 02:12:12.345')

    ,(3,'2013-10-04 02:12:12.345','2013-11-04 02:12:12.345')

    ;WITH cte2 (ID, Start_Range, End_Range) AS

    (SELECT ID, c.Start_Range,...

  • RE: Create a date table

    How about some DDL for the parent table and sample data with the expected outcome? That would help. Do you not know the largest date range possible for the query?...

  • RE: Create a date table

    Why can't you create a permanent date table? That would be better then building one on the fly every time.

  • RE: Problem with bcp and coalesce

    Try this:

    '"SELECT @colnames =COALESCE(@colnames + '','', '''') + column_name from TestData.INFORMATION_SCHEMA.COLUMNS where TABLE_NAME=''newtable'' and column_name in (' + @importedquery1 + '); select @colnames;" queryout C:\inetpub\wwwroot\cleansed\HeadersOnly.csv -c -T -SD3LICSQL02'

  • RE: Problem with bcp and coalesce

    Same issue.

    When ever something needs to be enclosed in single quotes make sure you use two when creating the dynamic string i.e.

    where TABLE_NAME = 'newTable' and column...<- regular SQL

    string =...

  • RE: Add text to first record part 2 case in where clause...

    This is a duplicate post. I have responded to your first post:

    http://www.sqlservercentral.com/Forums/Topic1514453-150-1.aspx

    Let's use that one going forward.

  • RE: a formula on a dataset filter?

    You have a few options here. The first thing is that a query like this maybe impacted by bad parameter sniffing so test it with and without recompile.

    1. Set @value...

  • RE: SQL Job

    This query will get you a list of job steps that are setup to run against a certain database:use msdb;

    go

    select *

    from sysjobsteps

    where subsystem = 'TSQL'

    and database_name = ?

    But you...

  • RE: Accidentally deleted all existing privilges for a domain account - Help

    The master will have your login premissions, but if you want to get back your DB premissions you will need to have the user databases. Now maybe you have orphaned...

  • RE: Problem with bcp and coalesce

    Oracle765 (11/13/2013)


    Hi All

    ok if the variable @importedquery I pass in equals 'softwaremanufacturer,productname,productversion' then that's the only column headings I will want

    I have got this far but its still showing an...

  • RE: Accidentally deleted all existing privilges for a domain account - Help

    So basically you will need the Master database to get the permissions for your logins and the user database(s) for the permissions for the users that are associated with those...

  • RE: Problem with bcp and coalesce

    I think you need this (notice the double single quotes before and after the comma:

    COALESCE(@colnames + '','', '')

  • RE: msdb backup fails.

    It doesn't sound like a SS issue. Sounds like an OS/HW issue. Is this a new file or are you appending/overwriting an existing file?

  • RE: Primary Key -Foerign Key

    If you are asking if the engine is working correctly it is. You can have nullable FKs. They do not check to see if there is a null column in...

Viewing 15 posts - 361 through 375 (of 496 total)