Forum Replies Created

Viewing 15 posts - 2,941 through 2,955 (of 13,460 total)

  • RE: Function to list passenger names?

    basically, you use a FOR XML to build the list, and then replace the LAST comma with an "AND":

    here's a working example, with the steps drawn out to help...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Having Clause results minus results from Left join query

    the EXCEPT operator can do that, but the number /types of columns must be the same in both queries.

    otherwise, show us your real queries instead of pseudocode, and we can...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Table design and PK design

    mstanl (11/15/2013)


    I have a team of Dev. that created a database with tables that each table has only one PK called ID as integer, in the child tables they join...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: How to find space used by a temporary table

    if you switch your database context to tempdb, sp_spaceused works for me:

    select top 100 * into #temp from edlogdetail

    use tempdb

    exec sp_spaceused #temp

    /*

    namerowsreserveddataindex_sizeunused

    #temp_<snip>_000000000187100 56...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Is this a bad habit i need to clean up after?

    GilaMonster (11/14/2013)


    Ed Wagner (11/14/2013)


    If your nonclustered has other columns included, it could prove useful in some queries, but since all nonclustered indexes inherit the value from the clustered index anyway,...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: changing collation for a database

    no easy way.

    you can use the sys.columns view to generate the suite of commands, and the commands might fail if there are any check constraints, default constraints , foreign keys...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Interactive query

    the accepting of parameters interactively would be part of an application, which just happens to call the SQL script when it's ready.

    SQLPlus for oracle has that feature built in, but...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Split a string at the first space after 50 characters

    dwain.c (11/13/2013)


    Lowell (11/13/2013)


    take a look at this thread, where there's a couple of different ways the same problem was tackled:

    Large String Value needs to be broken down into Human readible...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: BULK INSERT a string constant into a table

    instead of bulk insert directly into your destination table, use a staging table.

    what i've always done in this case is to bulk insert into a staging table, and then massage...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Split a string at the first space after 50 characters

    take a look at this thread, where there's a couple of different ways the same problem was tackled:

    Large String Value needs to be broken down into Human readible fixed lengths.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Query

    what you want to do here is use some customa ggregation:

    a SUM(CASE statement can help you generate the counts in a single statement

    something like this:

    SELECT

    COUNT(productid) AS Totalproduct,

    SUM(CASE WHEN productname...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Select between dates in another table.

    dwain.c (11/12/2013)


    Exotic JOIN? I think BOL must have forgotten to mention that one. 😛

    yeah the whole "exotic' naming convention for non traditional joins started back in 2007 with...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Bulk insert from file having varying number of columns

    Jeff Moden (11/12/2013)


    Lowell (11/12/2013)


    here's my linked server example for a 64 bit folder full of text files that may help:

    Very cool. I've not actually used the ACE drivers, yet...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Bulk insert from file having varying number of columns

    here's my linked server example for a 64 bit folder full of text files that may help:

    a couple of prerequisites:

    install the AccessDatabaseEngine_x64.exe from microsoft:

    http://www.microsoft.com/en-us/download/details.aspx?id=13255

    make sure you open an...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • RE: Select between dates in another table.

    the trick here is what some people call an "exotic" join, where it's not joining on discrete values, but rather on the criteria (between dates) you are looking for.

    Something like...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 15 posts - 2,941 through 2,955 (of 13,460 total)