Forum Replies Created

Viewing 15 posts - 481 through 495 (of 684 total)

  • RE: RECURSIVE SELECT STATEMENT..

    I agree, subqueries are cheap and nasty and it was the first thought that came to me. Now that I see you using min and max to get the...

  • RE: RECURSIVE SELECT STATEMENT..

    The above query might still work then - as long as you don't have more than 2 drivers. If there is only 1 driver then the Driver2 subquery will...

  • RE: RECURSIVE SELECT STATEMENT..

    I wouldn't say that this is advisable (or the best way to do it necessarily) but you could do it like so:

    This assumes that you will always have 2 rows...

  • RE: Dynamic getting value of table_name??

    Hi,

    sorry, declare @cmd as nvarchar(4000).

    Karl

  • RE: RECURSIVE SELECT STATEMENT..

    Hi,

    Assuming that it is PlateNumber and StartDate that determine a unique voyage then you can simply do the following.

    insert into somenewtable

    select distinct PlateNumber, StartDate

    from Voyage

    Hope that helps,

  • RE: Dynamic getting value of table_name??

    Hi,

    This cannot be the entire T-SQL script because it is incomplete. Anyway, to run the dynamic sql you can use the following method.

    while @@fetch_status = 0

    begin

    declare @cmd varchar(8000)

    set @cmd...

  • RE: 3 Arrays as the input parameters

    Yep,

    you're right. This is crazy . Anyway, here goes:

    --assumes that all params have same number of inputs

    while charindex('|',@param1) > 0

    begin

    ...

  • RE: Restoring a database

    Hi Varun,

    Just copy the backup file to your local machine and run the following statement:

    restore database newdatabase

    from disk = '\' --path and filename of backup file

    --options if any go here

    You...

  • RE: Update data

    Hi Zia,

    the update statement I provided will replace all occurrences of the string 'AF' with 'ADF' in the Items column. So it won't update fields like '12345F'.

    You just have...

  • RE: Update data

    Hi Zia,

    We'd need to know a little more about the format of the data in the Items column. Are the first 4 characters always numeric? Are the last...

  • RE: Need script to split a column fullname to first & last name

    Hi Brian,

    such a script would depend on how the data is stored in the full_name column. Specifically, how is the first and last name seperated - with a space,...

  • RE: Composite primary key autoincrement from 1

    Hi Nick,

    You can use the identity property on the OrderLineId colum.

    create table OrderLines

    (OrderLineId int identity,

    OrderId int,...etc)

    Incidentally, if you're going to have OrderLineId increment by one then it is fair...

  • RE: Is there a way to join this 3 tables

    Try this:

    select p1.ProductName as ParentProduct, p2.ProductName as ChildProduct

    from Products p1 join Kits k on k.ParentProductId = p1.ProductId

    join Products p2 on p2.ProductId = k.ChildProductId

    join Cart c on c.ProductId = p1.ProductId

    where c.CartId...

  • RE: Adding Users to Log Shipped DB

    Hi Chris,

    ideally you want to transfer the logins prior to setting up log shipping because once the primary server goes down you'll have little chance of transferring them from the...

  • RE: Set a variable value if it is null

    Hi,

    You can check the variable like this.

    if @BookRate is null set @BookRate = 0

    Or you can incorporate the check within the update statement itself using the ISNULL function.

    UPDATE BooksTbl SET...

Viewing 15 posts - 481 through 495 (of 684 total)