Forum Replies Created

Viewing 15 posts - 2,266 through 2,280 (of 2,458 total)

  • RE: Backup large database to multiple files

    Please don't double post.

    I inlcuded a better script for handling this

    in your original post that does not include any cursors or loops.

    P.S. if you search online for a way...

  • RE: Backup databases depending on the size to multiple files

    something like this...

    DECLARE @sql VARCHAR(8000);

    --Set your threshold here

    DECLARE @big int=1000--mb

    ;WITH dbs([dbid],size) AS

    (SELECT database_id,

    SUM(size)/128

    FROM sys.master_files

    GROUP BY database_id )

    SELECT @sql = COALESCE(@sql,'')+

    CASE

    WHEN size < @big

    THEN 'BACKUP DATABASE '+d2.name+'...

  • RE: SQL Queries for geting common values and uncommon values

    Based on what I can make of your post I think you are looking for this:

    --sample data

    DECLARE @x TABLE (id int not null, value char(1) not null, primary key(id,value));

    INSERT INTO...

  • RE: looping thru views

    Jeff Moden (3/15/2013)


    I suppose you could take what was said two ways. I may have taken it the wrong way.

    I was not 100% clear in what I said. I...

  • RE: looping thru views

    Jeff Moden (3/14/2013)


    Alan.B (3/7/2013)


    Cursors, loops and dSQL fall under the last choice column but this is one of those cases...

    For tables you would do this:

    EXEC sp_MSforeachtable'SELECT TOP 1...

  • RE: Group and Count from a table

    Well, Eugene beat me to it and with something better than what I put together.

    --Next time provide some DDL like so....

    --1) Lets setup that test data

    IF OBJECT_ID('tempdb..#classes') IS NOT...

  • RE: looping thru views

    kevaburg (3/14/2013)


    What about using:

    exec sp_MSforeachview 'select top 1 from ?'

    That is not a stored proc that comes from SQL Server. If you can run this:

    exec sp_MSforeachview 'select top 1 from...

  • RE: Word wrapping query output

    Mick Opalak (3/13/2013)


    No, I'd like not just the first 50 characters but all of the characters in the field. I'd like the first 50 characters, then a carriage return,...

  • RE: Split A String into 4 parts

    Eugene Elutin (3/13/2013)


    Alan.B (3/13/2013)


    Eugene Elutin (3/13/2013)


    declare @filename varchar(100)

    set @filename = 'Notes_20130204_003015.txt';

    select PARSENAME(replace(@filename,'_','.'),4)

    select PARSENAME(replace(@filename,'_','.'),3)

    select PARSENAME(replace(@filename,'_','.'),2)

    select PARSENAME(replace(@filename,'_','.'),1)

    Fantastic use of PARSENAME! Wow!

    Not really. Quite slow one, actually. But will suite to...

  • RE: Split A String into 4 parts

    Eugene Elutin (3/13/2013)


    declare @filename varchar(100)

    set @filename = 'Notes_20130204_003015.txt';

    select PARSENAME(replace(@filename,'_','.'),4)

    select PARSENAME(replace(@filename,'_','.'),3)

    select PARSENAME(replace(@filename,'_','.'),2)

    select PARSENAME(replace(@filename,'_','.'),1)

    Fantastic use of PARSENAME! Wow!

  • RE: Part Table or Procedure not updating

    First, welcome to SSC.

    I suggest you re-post this under the programming - general forum and be prepared to provide a little extra detail; you will have better luck. What...

  • RE: Single Update Query - Required

    This should get you started...

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

    DROP TABLE #table1;

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

    DROP TABLE #table2;

    CREATE TABLE #table1 (sno int unique NOT NULL, [sid] int NULL, sname varchar(2) unique...

  • RE: Creating Stored Procedure

    dsrapid (3/11/2013)


    Hi,

    I have below table:

    ID URL

    1 https://google.com

    2 https://facebook.com

    3 https://yahoo.com

    4 https://gmail.com

    I am trying to create a procedure where I take the input...

  • RE: Combine variable and select statement

    Its worth noting that, if you do not assign a value to @EndUserDel it will return NULL value. See my comments in the code below

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

    DROP TABLE...

  • RE: looping thru views

    rummings (3/11/2013)


    Alan,

    Thank you for the code.... it worked great!

    Charlie

    Any time.

Viewing 15 posts - 2,266 through 2,280 (of 2,458 total)