Forum Replies Created

Viewing 15 posts - 7,096 through 7,110 (of 8,731 total)

  • RE: DATETIME with date and time

    To display it, you need to use CONVERT with format code 120.

    You should, however, store datetime values as datetype types which have no format predefined.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Help with combining rows

    Maybe this would give you a clue on how to do it while you're inserting your data into your table variable. Why are you inserting into the table variable? Are...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: T-SQL help on datetime

    I can't reproduce your error. What are you using instead of '?'?

    Can you post DDL of the table?

    Here's what I used to test.

    WITH SomeTable([year],[month],[day]) AS(

    SELECT 2001,9,14 UNION ALL SELECT 2001,9,15)

    SELECT...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Query Question Using Distinct concept in table joins

    The problem is that your JOINS are duplicating the rows because of the one-to-many relationship with tables C and D.

    I'm leaving here 3 options that you might consider. On the...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Automatically import csv content into SQL Server

    You have a problem here. You need to do something but you don't have the permissions to do it.

    I'd say that you need to talk to your manager, DBA or...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: How to pivot but to keep one column unchanged

    I'm glad that you got a solution. Be sure to understand it, that's why I inclued a link to an article that goes step by step on how the solution...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: group by column as sub header

    I had a similar option to Nevyn but using a subquery.

    SELECT citation

    FROM(

    SELECT header,

    CAST( header AS varchar(200)) AS citation,

    1 AS roworder

    FROM Table_1

    GROUP BY header

    UNION ALL

    SELECT header,

    citation,

    2 AS...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Automatically import csv content into SQL Server

    Deries (1/27/2014)


    Thank you Jeff, Could you or anyone give me a sample code to test it out.

    Read what I posted 😛

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: How to pivot but to keep one column unchanged

    You could easily use a cross tabs approach to this problem. You can read more about this method on the following article: http://www.sqlservercentral.com/articles/T-SQL/63681/

    If you have any questions after reading the...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Need expression for start date and end date

    I would create a calendar table and include the expression in a column so you can use it in the queries.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Automatically import csv content into SQL Server

    And there's a recently published article by Jeff on BULK INSERT that will help you as an introduction to your process.

    http://www.sqlservercentral.com/articles/BCP+(Bulk+Copy+Program)/105867/

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: FizzBuzz

    chillw1nston (1/27/2014)


    window function version

    SELECT TOP 100 --*

    --,

    CASE WHEN ROW_NUMBER() OVER (ORDER by object_id) % 3 = 0 THEN 'FIZZ'

    WHEN ROW_NUMBER() OVER (ORDER by object_id) % 5 = 0 THEN...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: How to use scalar function without WHILE

    There are some points that confuse me.

    You say you need the first 50 entries from your table. How do you define the first 50? What order do you have? Why...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Need expression for start date and end date

    Do you have a calendar table?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Remove Leading Zeros

    Hi Andrew,

    Here are two options you might consider.

    WITH SampleData AS(

    SELECT '005863913 00002' String)

    SELECT CAST( LEFT( String, CHARINDEX( ' ', String)) AS Int) AS AsInteger,

    SUBSTRING( LEFT( String, CHARINDEX( ' ', String)),...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 15 posts - 7,096 through 7,110 (of 8,731 total)