Forum Replies Created

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

  • RE: How to get the previous weeks data based on week ending

    Which bit are you struggling with - the aggregate function and GROUP BY, the CROSS APPLYs, the DATEADD and DATEDIFF, or something else?

    Please confirm that you are indeed using SQL...

  • RE: Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '-'.

    Assuming you're running this in SSMS, you can double-click on the error and it'll take you to the line in the code. In this instance, I think it's the...

  • RE: How to get the previous weeks data based on week ending

    Here you go. If you don't feel comfortable changing DATEFIRST, you can do some modulo magic on DATEPART(dw,RegistrationDateTime) so that you get the right numbers.

    set DATEFIRST 5 -- set...

  • RE: Scheduled Job

    A job can have more than one schedule. It's easier to have multiple schedules than multiple jobs!

    John

  • RE: How to exclude text values and only include numbers in a varchar column

    Careful, though. Add these rows to your table and try again. I'm sure there are other values that might trip you up, as well.

    insert into #Test(ResultValue) values('3E+1')

    insert into...

  • RE: Help with sorting data from two tables

    csb5036 (9/28/2016)


    USE HandsOnOne;

    SELECT CustomerName, City, State

    FROM Customer, Address

    ORDER BY ZipCode ASC, CustomerName ASC

    When I execute this code, my return is 16 items instead of 4. Somehow, each customer is being...

  • RE: Select top ..., with extra conditions

    Alex

    I've no idea what a PLC is, but I think I can answer your question without knowing! If I were you, I'd put all the PLC variables into a...

  • RE: Using a variable as database name

    I've never tried using variables in a RESTORE statement before, but something like this should work:USE master;

    DECLARE

    @DestDB sysname = 'CIFT01'

    ,@BakFile varchar(260) = 'D:\Microsoft SQL Server\MSSQL11.SQL2012\MSSQL\Backup\2016-09-27_19-00_CIFT01.bak'

    ,@LogicalDataFile sysname

    ,@LogicalLogFile sysname;

    SELECT

    @LogicalDataFile = @DestDB

    ,@LogicalLogFile =...

  • RE: Using a variable as database name

    For five databases, I think I'd just write out the RESTORE statement five times and run the whole lot. The database names aren't going to change each time you...

  • RE: Violation of Primary key

    Ansharah (9/28/2016)


    If know clear root cause of this problem. I can avoid in future since its in Prod.

    Like I said, someone reseeded the identity. Since you need sysadmin, db_owner...

  • RE: Violation of Primary key

    It looks as if someone has reseeded the identity at some point. Find out the maximum value of piagam_id, and reseed the identity again to that value plus one.

    John

  • RE: SQL Join

    If you always have a space in the middle of your postcode, and you want to match everything to the left of the space, change your join predicate to this:

    LEFT(N.[Office...

  • RE: Transaction Log Question

    Mike

    Three reasons, really:

    (1) To minimise physical fragmentation. If your file grows in small chunks, you're likely to have bits of it scattered all over the disk.

    (2) To avoid having...

  • RE: Help with the query

    Your business rules don't make any sense to me. Why, when you have different values in ReferenceTable2 for City and for State, do the two rows in your expected...

  • RE: Generate Create Script for a table - include indexes, keys, statistics

    Find a SQL Server instance that isn't doing anything - a test instance on your desktop/laptop for example. In SSMS, go to Tools -> Options -> SQL Server Object...

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