Forum Replies Created

Viewing 15 posts - 106 through 120 (of 429 total)

  • RE: email query results

    Original poster asked to have multiple fields not multiple values of fname. There is no need to make multiple selects. It will work fine with

    select @body1=@body1 + char(10) + firstname...

  • RE: use a variable in an ORDER BY clause?

    The post http://www.aspfaq.com/show.asp?id=2501 also says use CASE in ORDER BY CLAUSE. Dynamic SQL should be last thing to think.

    For multiple columns use

    EXEC('SELECT * FROM blat ORDER BY ' + @col +...

  • RE: email query results

    select @body1=@body1 + char(10) + firstname, lastname from tblstaff 

    You are assining a value to varaible @body1. What are you trying to do with lastname.

    Query should be

    select @body1=@body1 + char(10) +...

  • RE: How do I set a variable to a column value in a cursor

    CREATE PROCEDURE [dbo].[proc_O2_Add_SPID_TariffID]

     AS

    SET NOCOUNT ON

    SET ANSI_PADDING ON

    DECLARE @SPID  INT

    DECLARE @TariffID  VARCHAR(3)

    DECLARE @TariffName  VARCHAR(50)

    DECLARE @MobileNo VARCHAR(25)

    DECLARE @RecordLength INT

    Declare rstO2NetworkBase CURSOR Forward_Only

    FOR

     SELECT SPID, TariffID, TariffName, MobileNo, RecordLength

     FROM tbl_O2_Base_NW_Import

    OPEN rstO2NetworkBase

    FETCH NEXT FROM rstO2NetworkBase...

  • RE: Select Statement Help

    Can you give more details. When you iterate 1,2,3,4 again how to you realate that with another table.

  • RE: Updating Error -- Using Convert Function

    But I would want to convert the datatypes of login and logout as DATETIME since if the data is like below it would give a negative time.

    SET NOCOUNT ON

    GO

    DECLARE @myTable...

  • RE: Updating Error -- Using Convert Function

    SET NOCOUNT ON

    GO

    DECLARE @myTable TABLE

    (

    myID  INT,

    srawlogin VARCHAR(25),

    srawlogout VARCHAR(25) NULL,

    CallTime  INT NULL

    )

    INSERT @myTable (myID, srawlogin) VALUES (1, '11:45:21')

    DECLARE @srawlogout VARCHAR(25)

    SET @srawlogout = '11:45:55'

    UPDATE @myTable

    SET

     srawlogout = @srawlogout,

     CallTime = DATEDIFF(SECOND, CONVERT(DATETIME, srawlogin), CONVERT(DATETIME, @srawlogout))

    WHERE

     myID =...

  • RE: Searching for all the words

    My Mistake.

    I thought any of the words. Not all the words.

    I still go with dynamic SQL with AND instead of OR because following search wouldn't return any rows. The words...

  • RE: SELECT query stmt inside a Stored Procedure

    When you use ADO or ADO.net it would be possible to use the resultset in fron end processing. It is used in real world applications.

    Within another procedure or with SQL...

  • RE: SELECT query stmt inside a Stored Procedure

    CREATE TABLE #Temp(Col1 datatype, col2 datatype, ...)

    INSERT #Temp Exec sp_test

    or

    DECLARE @myTemp TABLE (Col1 datatype, col2 datatype, ...)

    INSERT @myTemp Exec sp_test

    Will get the result set into the temp table of current...

  • RE: How to use joins with multiple Tables....

    I agree Ian's solution is easy to undersatnd and maintain. I am not sure about the efficiency but I would take that query instead of what I gave for simplicity.

  • RE: Datetime shenanigans

    I would assume for British

    DD/MM/YYYY and YYYY-DD-MM formats will work. Date comes before month.

  • RE: SELECT query stmt inside a Stored Procedure

    http://msdn.microsoft.com/library/en-us/tsqlref/ts_sa-ses_9sfo.asp?frame=true

    You can use the results whatever way you want for any purpose.

  • RE: How to use joins with multiple Tables....

    SET NOCOUNT ON

    GO

    DECLARE @emc_messageinfo TABLE

    (

    [Table] INT,

    Code INT,

    Remark VARCHAR(25)

    )

    INSERT @emc_messageinfo

    SELECT 1, 1, 'This is Customer' UNION

    SELECT 1, 2, 'This is Customer' UNION

    SELECT 1, 3, 'This is Customer' UNION

    SELECT 1, 4, 'This is Customer' UNION

    SELECT 2, 1, 'This is...

  • RE: Searching for all the words

    You may want to use dynamic SQL. I don't think this solution is elegant.

    SET NOCOUNT ON

    GO

    CREATE TABLE #MyTable

    (

    myData VARCHAR(100)

    )

    INSERT INTO #MyTable

    SELECT 'Basically' UNION

    SELECT 'I' UNION

    SELECT 'want' UNION...

Viewing 15 posts - 106 through 120 (of 429 total)