Forum Replies Created

Viewing 15 posts - 3,721 through 3,735 (of 5,393 total)

  • RE: T-SqL help please

    ;WITH groupedOrders AS (

    SELECT Err_Stmt, Error_At_line, COUNT(*) AS [count(*)]

    FROM orders1111

    GROUP BY Err_Stmt, Error_At_line

    )

    SELECT *, ID_Number = STUFF((

    SELECT ',' + ID_Number

    FROM orders1111

    WHERE Err_Stmt = G.Err_Stmt

    AND Error_At_line = G.Error_At_line

    FOR XML PATH('')

    ),1,1,SPACE(0))

    FROM...

    -- Gianluca Sartori

  • RE: Suppress output when changing configuration

    I'm afraid there's no way.

    What you see is the output of a RAISERROR command. I'm not aware of any way to get rid of it.

    -- Gianluca Sartori

  • RE: Sub select anomaly

    I used the code tag.

    -- Gianluca Sartori

  • RE: Sub select anomaly

    Here's your code formatted properly.

    CREATE TABLE #Select (SSN VARCHAR(10))

    CREATE TABLE #SubSelect (XXX VARCHAR(10))

    INSERT INTO #Select (SSN)

    VALUES ('123456780')

    INSERT INTO #Select (SSN)

    VALUES ('123456788')

    INSERT INTO #Select...

    -- Gianluca Sartori

  • RE: Ignoring error row in Bulk Insert

    You specified MAXERRORS = 0, so you don't allow errors during import.

    BOL states:

    MAXERRORS = max_errors

    Specifies the maximum number of syntax errors allowed in the data before the bulk-import operation is...

    -- Gianluca Sartori

  • RE: Suppress output when changing configuration

    I suppose you want this because you're changing configuration from an application and it raises an error when the message is encoutered, right?

    Then, the answer is simple: don't do that.

    Changing...

    -- Gianluca Sartori

  • RE: SQL Server 2005 (apparently) uses only half of the CPU's

    I have seen something similar with our Oracle server, running AIX 6.1 on a box with 8 Power7 CPUs.

    The first 4 CPUs are almost always fully loaded, while the remaining...

    -- Gianluca Sartori

  • RE: get the first Sunday and last Saturday

    With a few changes you can have up to 12 years.

    With a real tally table[/url] you could have all the years you want.

    -- Set year in a variable

    DECLARE @StartYear int

    DECLARE...

    -- Gianluca Sartori

  • RE: get the first Sunday and last Saturday

    This should fo the trick for you:

    -- Set year in a variable

    DECLARE @Year int

    SET @Year = 2010

    ;WITH Months AS (

    -- Create a month numbers CTE

    SELECT 1 AS MonthNumber

    UNION ALL SELECT...

    -- Gianluca Sartori

  • RE: Renameing a column in all tables in a sql 2008 database

    You can use sp_rename:

    EXEC sp_rename 'schema.table.name', 'newname', 'COLUMN'

    As for adding new columns, you can use ALTER TABLE:

    ALTER TABLE tablename ADD [column definition]

    -- Gianluca Sartori

  • RE: I need to create a sp such that it calls a DTS package with in a SP

    Create a job with appropriate name (e.g. 'DO SOME STUFF').

    Add new operating system step and set the command as follows:

    DTSRUN /E /S<serverName> /N<DTSPackageName>

    Save the job.

    Open a query window and issue:

    EXEC...

    -- Gianluca Sartori

  • RE: Is there a way to filter the parameter(s) within OVER(PARTITION BY ....) ? ? ?

    You're welcome.

    Glad I could help

    -- Gianluca Sartori

  • RE: I need to create a sp such that it calls a DTS package with in a SP

    To run a DTS packae directly, you would have to use xp_cmdshell, which is not recommeded.

    I would instead create a SQL Agent job that runs the package and then start...

    -- Gianluca Sartori

  • RE: find proc among all databases

    This should do the trick:

    IF OBJECT_ID('Tempdb..#Procedures') IS NOT NULL

    DROP TABLE #Procedures

    CREATE TABLE #Procedures (name varchar(128))

    DECLARE @ProcedureName varchar(20)

    SET @ProcedureName = 'sp_start_job'

    DECLARE @sql varchar(4000)

    SET @sql = 'USE [?]; INSERT INTO #Procedures SELECT...

    -- Gianluca Sartori

  • RE: Query help

    It might not be the answer you'd like to hear, but you should not do this on the database side. Do it in the app side instead.

    If you insist doing...

    -- Gianluca Sartori

Viewing 15 posts - 3,721 through 3,735 (of 5,393 total)