Forum Replies Created

Viewing 15 posts - 2,161 through 2,175 (of 2,458 total)

  • RE: Query Help - To delete old files

    GregoryF (8/8/2013)


    I use forfiles (google it for the reference on how to use) call from xp_cmdshell. It alows be to delete files older than n days, and you can...

  • RE: Query Help - To delete old files

    Sreejith! (8/8/2013)


    Hi All,

    Looking for assistance to develop T-SQL code

    Requirement is to delete old files from directory & its sub-directories(say F:\Temp\test\), which were placed in directory before 1 week...

  • RE: Pivot columns

    ksrikanth77 (8/8/2013)


    The Data I have in my Category code column in my source table is as below, as an example I just posted it as A B C D.

    My...

  • RE: Pivot columns

    Below is a script that:

    1) Creates the sample data

    2) Queries the sample data for the desired results

    -- (1) Let's build the table structure

    DECLARE @source_table TABLE (ID int primary key,...

  • RE: SELECT ... INTO NewTable without nulls

    You could do something like this:

    USE tempdb;

    DECLARE @source_table varchar(100)='sys.all_columns',--Source Table

    @dest_table varchar(100)='new_table',--destination table (created by SELECT INTO)

    @column varchar(100)='is_column_set',--column to swich to NOT NULL

    @sql_prep varchar(1000),

    @insert_sql varchar(1000),

    @alter_sql varchar(1000),

    @data_type varchar(100);

    SET @sql_prep='IF OBJECT_ID('''+DB_NAME()+'..'+@dest_table+''')'+' IS...

  • RE: sp_spaceused columns?

    I created a stored procedure you can use.

    Sample data:

    use tempdb;

    IF OBJECT_ID('tempdb.dbo.demo') IS NOT NULL DROP TABLE dbo.demo;

    CREATE TABLE dbo.demo (col1 varchar(1000), col2 varchar(1000));

    WITH tally(n) AS (SELECT ROW_NUMBER() OVER (ORDER...

  • RE: Starting point of a Join

    sharonsql2013 (8/2/2013)


    What do you mean by a staring point of a Join?

    I am creating a join with some tables and I have been asked table A to be starting point...

  • RE: Need help with T-SQL to combine email addresses

    Sean Lange (8/2/2013)


    heh I forgot the semicolon in my post. Alan you don't need to do this with a subselect, just a simple query works.

    SELECT cEmail + ';'

    FROM #people

    FOR XML...

  • RE: Need help with T-SQL to combine email addresses

    You don't need a loop to do what you were trying to do. This would do the trick

    DECLARE @emails varchar(5000)=''

    SELECT @emails=@emails+';'+cEmail

    FROM dbo.people;

    This technique, however, can give you data issues... The...

  • RE: Easy (I hope) join question

    This is what I came up with

    --SAMPLE DATA

    IF OBJECT_ID('tempdb..#table_A') IS NOT NULL

    DROP TABLE #table_A;

    IF OBJECT_ID('tempdb..#table_B') IS NOT NULL

    DROP TABLE #table_B;

    CREATE TABLE #table_A (name varchar(20), [address] varchar(20));

    CREATE TABLE #table_B (name varchar(20),...

  • RE: String Manipulation

    I put together a little sample code and a few examples (note my comments) for a couple common scenarios

    DECLARE @x TABLE (val varchar(20));

    INSERT @x VALUES ('two words'),('two words '),('oneword'),(' leading...

  • RE: query to get the size of all indexes in a database

    You could do something like this:

    IF OBJECT_ID('tempdb..#indexInfo') IS NOT NULL

    DROP TABLE #indexInfo;

    SELECT TOP 0

    t.TABLE_CATALOG AS db,

    t.TABLE_SCHEMA AS SchemaName,

    OBJECT_NAME(i.OBJECT_ID) AS TableName,

    ...

  • RE: Effective T-SQL for Median

    TheSQLGuru (7/30/2013)


    Fortunately for you SQL 2012 has much better Windowing Function support. Look into the PERCENTILE_CONT function. I also HIGHLY recommend you purchase Itzik Ben-Gan's SQL Server 2012...

  • RE: Effective T-SQL for Median

    dkschill (7/30/2013)


    Is this an effective way to find median?

    CREATE TABLE #T (i TINYINT);

    GO

    INSERT INTO #T

    SELECT ABS(CHECKSUM(NEWID())) % 250

    GO 1000

    ;WITH t AS (SELECT i, ROW_NUMBER() OVER (ORDER BY i) AS n,...

  • RE: Need T-SQL Query Help- Urgent

    ChrisM@Work (7/29/2013)


    Thanks for the very generous feedback, Mr Kapsicum.

    If you're interested in how the method works, here's an excellent article by Dwain Camps[/url].

    I have nothing to add to this thread...

Viewing 15 posts - 2,161 through 2,175 (of 2,458 total)