Forum Replies Created

Viewing 15 posts - 1,036 through 1,050 (of 2,007 total)

  • RE: Wrapper to run stored procedure many times

    adrian.facio (1/17/2012)


    Hi,

    I sometimes like to construct the code to execute the procedures with a script like the following, it has been very useful to me lot of times, but it...

  • RE: sp_executesql

    DECLARE @TblName varchar(50)

    DECLARE @ColValue int

    set @ColValue=30

    set @tblName='MyTable'

    execute sp_executesql N'Select * from '+ QUOTENAME(@tblName) + ' where somecol = @ColVal' , '@ColVal int', @ColValue;

  • RE: Union Issue

    .Netter (1/17/2012)


    But im getting the following error

    "Msg 457, Level 16, State 1, Line 1

    Implicit conversion of varchar value to varchar cannot be performed because the collation of the value is...

  • RE: Union Issue

    DDL and sample data would be very useful, click this link to see how best to lay it out. Help us to help you![/url] 😀

    Off the bat, your UNION...

  • RE: Sanity Check - using CASE in WHERE clauses

    Rayven (1/17/2012)


    Grief, were you sitting on the forum!!! That was an incredibly fast response - thanks! :w00t:

    Just lucky 😀

    As I said, if you're using 2008 then you can get similar...

  • RE: Sanity Check - using CASE in WHERE clauses

    Gail wrote a blog on the issue you're describing[/url].

    Dynamic is the best way to go (or RECOMPILE) - and more vigorous testing! 😛

  • RE: convert column with numbers to a specific date format

    SQL Kiwi (1/17/2012)


    mic.con87 (1/16/2012)


    please can you explain the CROSS APPLY...

    See:

    http://www.sqlservercentral.com/articles/APPLY/69953/

    http://www.sqlservercentral.com/articles/APPLY/69954/

    LEN

    http://msdn.microsoft.com/en-us/library/ms190329.aspx

    ...and also why you used a CAST and not a CONVERT.

    I tend to prefer CONVERT because it supports explicit styles. ...

  • RE: Make New Table Daily

    guerillaunit (1/16/2012)


    Cadavre,

    Is the code you posted the daily job scheduling?

    Yes. You'd need to go through and change the job name, the table names, schema names and database names. Also, it's...

  • RE: convert column with numbers to a specific date format

    mic.con87 (1/16/2012)


    I think I have found the problem. There are 64 dates that have a problem. These can be defaulted to null. The leading zero disappears when you create the...

  • RE: convert column with numbers to a specific date format

    The most likely issue is that the data has been entered in multiple formats, e.g. DDMMYYYY and MMDDYYYY

    This makes the whole task harder because you can't know which way you...

  • RE: Make New Table Daily

    Bit of a stab in the dark: -

    USE [msdb]

    IF EXISTS (

    SELECT job_id

    FROM msdb.dbo.sysjobs_view

    WHERE name = N'YourJobName'

    )

    BEGIN

    EXEC msdb.dbo.sp_delete_job @job_name = N'YourJobName',

    @delete_unused_schedule = 1

    END

    DECLARE @jobId BINARY (16)

    EXEC msdb.dbo.sp_add_job @job_name = N'YourJobName',

    @enabled =...

  • RE: convert column with numbers to a specific date format

    BEGIN TRAN

    CREATE TABLE #Dates (CurrentDateFormat int, IncidentDate Date )

    INSERT INTO #Dates VALUES (0,'1900-01-01') --All 0's to default to '1900-01-01'

    INSERT INTO #Dates VALUES (14041979,'1979-04-14')

    INSERT INTO #Dates VALUES (04021983,'1983-02-04')

    INSERT INTO #Dates VALUES...

  • RE: multiple column in one column with same id

    Apologies, I didn't read the whole thread when I replied.

    BEGIN TRANSACTION

    CREATE TABLE mytable (id INT identity(1, 1),PersonID INT,Unit VARCHAR(10))

    INSERT INTO mytable VALUES (1,'Che')

    INSERT INTO mytable VALUES (1,'Mat')

    INSERT INTO mytable VALUES...

  • RE: Creating million row test tables?

    SQL Kiwi (1/16/2012)


    Jeff Moden (1/16/2012)


    Generating the data with a script that uses NEWID() avoids another problem... backwards compatibility for restores. Here's what happens when someone using SQL Server 2005...

  • RE: Getting the difference from current row and previous row

    Your issue is probably due to your index.

    Try this replication script: -

    BEGIN TRAN

    SET NOCOUNT ON

    IF object_id('tempdb..#testEnvironment') IS NOT NULL

    BEGIN

    DROP TABLE #testEnvironment

    END

    --1,000,000 Random rows of data

    ;WITH CTE AS (

    SELECT DATEADD(HOUR,ROW_NUMBER() OVER...

Viewing 15 posts - 1,036 through 1,050 (of 2,007 total)