Forum Replies Created

Viewing 15 posts - 6,946 through 6,960 (of 8,731 total)

  • RE: Cursor and update

    If it works for you, then is fine. If you want to continue to work with SQL, you should start trying to do it "the right way" because this DB...

    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 Help : Remove Number from string

    MyDoggieJessie (2/12/2014)


    I'd create a little scalar function, should work like a charm:

    I wouldn't because it won't, it will just cause performance issues.

    I'd create an inLine Table-valued function.

    CREATE FUNCTION dbo.ReturnOnlyChars(

    @String varchar(8000)--...

    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: unpivot error conflicts with the type of other columns specified in the UNPIVOT list

    Can you post the code you're using?

    You shouldn't have problems, but if you do, you might want to CAST all your int columns into decimal(13,4). You might also have an...

    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 Part of a String

    Here are two options.

    DECLARE @Codes TABLE

    (

    Codes VARCHAR(10)

    )

    INSERT INTO @Codes

    ( Codes )

    VALUES ('ABC-0350'), ('DEF-00430')

    SELECT Codes,

    STUFF(Codes, 1, CHARINDEX('-', Codes), ''),

    SUBSTRING(Codes, CHARINDEX('-', Codes) + 1, 8000)

    FROM @Codes

    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 Pivot Question

    Have you tested again?

    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: Grouping distinct values by date

    For some performance improvement you could pre-aggregate your data. Note that I'm suming the counts but is still a count.

    SELECT [date],

    SUM( CASE WHEN typesold = 1 THEN amount ELSE 0...

    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: create a table with two primary keys.

    sqlvogel (2/11/2014)


    In principle any candidate key of a table can be called "primary", meaning it is designated as the "preferred" identifier for information in that table.

    That's the point. A 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: Can i do this (pivot)

    I'm not sure what you need without DDL, sample data and expected results.

    However, those articles have the basic theory to pivot queries both static and dynamic.

    For more help, please read...

    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: Can i do this (pivot)

    It's possible, take a look at this articles:

    Cross Tabs: Part 1[/url]

    Cross Tabs: Part 2[/url]

    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: Concatinating date and string

    Then you'll need to cast as bigint before multiplying.

    (CAST( YEAR(getdate()) AS bigint) *10000000)

    Why do you need a value like this anyway? What's your serial column data type?

    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: IDENTITY_INSERT ON but error about column list, even though using column list

    You have to add the column list to the table you're inserting into.

    insert into [AdventureWorks2012].[Sales].[SalesOrderDetail]( <Column list goes here>)

    values(43665, 1, 'HkTest', 25, 715, 1, 25.00, 5.00, 25.00, 'B207C96D-D9E6-402B-8470-2CC176C42283', getdate());

    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: Replace a reserved keyword

    Eugene Elutin (2/11/2014)


    2. I wouldn't rename your "pivot" column as it may be used under that name by many calling processes. In this case you will need to change them...

    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: Execute an SP from one server against multiple others

    Have you tried Central Management Servers?

    http://blogs.technet.com/b/lobapps/archive/2013/01/01/manage-multi-servers-effectively-using-sql-server-central-management-server-cms.aspx

    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: Concatinating date and string

    The problem is that '0000000' is being converted to int and adding it to the year. Instead of converting th char and then to int, I would just use some...

    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: Generating CREATE TABLE Scripts for a large number of tables

    You could as well right-click the database, go to Tasks-> Generate Scripts... and it will help you to script all the objects you need from the db.

    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 - 6,946 through 6,960 (of 8,731 total)