Forum Replies Created

Viewing 15 posts - 91 through 105 (of 241 total)

  • Reply To: Simplest way to (automatically) output query results to csv

    From SQL you can try to use ACE driver. Something like this:

    INSERT INTO OPENROWSET('Microsoft.ACE.OLEDB.12.0',
    'Text;Database=C:\Temp\;HDR=YES;FMT=CSVDelimited',
    'SELECT * FROM [FileName.csv]')
    SELECT Field1, Field2, Field3
    FROM MyTable

    Please note that target file must already...

    --Vadim R.

  • Reply To: How to write the case statement on a case statement ?

    Are we talking about nesting in CASE expression? If so, you can start another CASE after THEN. Something like this:

    CASE lineid1
    WHEN 'APPROVED'
    THEN...

    --Vadim R.

  • Reply To: t-sql 2012 replace part of value in a field with a different value

    Not sure if I got it correctly.... If you know sequence of characters you replacing use REPLACE() function. If you need to replace at certain positions, use STUFF() function.

    --Vadim R.

  • Reply To: A single query to display the result of multiple date selection in month columns

    Which aggregate you use is up to you. You need count - use COUNT. You can also use SUM to count things in CASE. Other than that follow the technique...

    • This reply was modified 7 years, 2 months ago by rVadim. Reason: Fixed code

    --Vadim R.

  • Reply To: File System Manipulation Within a Function

    As Ben had shown, you can use Insert...EXEC in the procedure to capture xp_cmdshell output into table. Then parse it in the function.

    You can do file manipulation in the external...

    • This reply was modified 7 years, 2 months ago by rVadim. Reason: Corrected code appearance

    --Vadim R.

  • Reply To: Splitting Rows Into Columns

    Sure, if number of columns is unpredictable you'll need dynamic SQL. But inside that dynamic SQL you may implement one of the crosstab techniques. The only other way I can...

    --Vadim R.

  • Reply To: Splitting Rows Into Columns

    Here is one way doing this:

    SELECT 
    [COLUMNS] = 'TID',
    [2019-01-01] = MIN(CASE WHEN LDate = '20190101' THEN TID END),
    [2019-01-03] = MIN(CASE WHEN...

    --Vadim R.

  • Reply To: Splitting Rows Into Columns

    Your desired output doesn't seem right. There is no 'user2' in FName column, there is no 'user1' in LName. How come they appear in respecting output rows. It's a crosstab...

    --Vadim R.

  • Reply To: Getting the columns

    Also, if I'm not mistaken, default schema is ignored for sysadmins. They always get dbo.

    --Vadim R.

  • Reply To: Creating My Table

    I don't think schema will be created in CREATE TABLE even if you grant CREATE SCHEMA permission to the user. You'll need separate statement for that.

    --Vadim R.

  • RE: Today's Math

    I attempted to answer today, May 27. Naturally selected #4....

    This queston has timing issue. 🙂

    --Vadim R.

  • Viewing 15 posts - 91 through 105 (of 241 total)