Forum Replies Created

Viewing 15 posts - 151 through 165 (of 206 total)

  • RE: Using the Over Partion to create an instance count

    I couldn't figure out how to get mine to work with the new data so I modified Lamprey13's.

    I think this will work.

    CREATE TABLE #test (ptm_id INT, wl_id INT, [date] date,...

  • RE: Using the Over Partion to create an instance count

    I think I broke both of them:

    CREATE TABLE #test (ptm_id INT, wl_id INT, [date] date, cancellation CHAR(1))

    INSERT INTO #test VALUES (1, 203, '01/08/09', 'C')

    INSERT INTO #test VALUES (1, 203, '01/20/09',...

  • RE: Using the Over Partion to create an instance count

    Well here is what I came up with:

    CREATE TABLE #test (ptm_id INT, wl_id INT, [date] date, cancellation CHAR(1))

    INSERT INTO #test VALUES (1, 203, '01/08/09', 'C')

    INSERT INTO #test VALUES (1, 203,...

  • RE: Update with join tables

    j.grimanis (7/31/2009)


    Hi,

    I have the following statement

    UPDATE tbl_service_models

    set tbl_service_models.Maintenance_Standard_KM=20000

    JOIN tbl_family on

    tbl_service_models.car_family_id=tbl_family.car_family_id

    where tbl_family.brand_code=6 and tbl_service_models.Maintenance_Standard_KM=15000

    and I get error:

    Msg 156, Level 15, State 1, Line 3

    Incorrect syntax near the keyword 'JOIN'....

  • RE: Calculating custom score

    Here is what I did. There is probably a better way but this was the first thing that came to mind.

    CREATE TABLE #tblResults (participant_id INT, endTime TIME)

    INSERT INTO #tblResults...

  • RE: I need to combine two SQL Statements in one

    Can you change the script below to reflect the table structures you are have.

    CREATE TABLE #tblContracts (Contract_ID INT, ControlNumber INT,

    ContractStatus CHAR(1), SSN CHAR(11), IT_Code VARCHAR(5))

    INSERT INTO #tblContracts VALUES (1,...

  • RE: Show permissions for database user

    Is something like this what you are looking for:

    SELECT NAME, permission_name, class_desc , OBJECT_NAME (major_id) , state_desc

    FROM sys.database_permissions dp

    INNER JOIN sys.database_principals pri ON dp.grantee_principal_id = pri.principal_id

  • RE: I need to combine two SQL Statements in one

    It could be that the caffine is still not completely into my system yet but I am not sure what results you are expecting. Do you want multiple rows...

  • RE: JOIN Where A Date Is < Min(Date)

    Here is the script with the dummy data for anyone else who might need it.

    CREATE TABLE #period (period_end DATETIME, period_month INT, period_year INT)

    INSERT INTO #period VALUES ('07/26/09', 12,...

  • RE: I need to combine two SQL Statements in one

    It's early but here is a quick shot.

    Select @LOSS_TA = sum(CASE WHEN I.IT_CODE = 'TA' THEN 1 ELSE 0 END),

    @LOSS_SRIP = SUM(CASE WHEN I.IT_CODE = 'SRIP' THEN...

  • RE: Securing Stored Procedures from being seen

    SELECT *

    FROM sysobjects so

    WHERE type = 'P' -- Stored Procedure type

    AND PERMISSIONS(so.id) & 32 = 32 -- Execute rights...?

    ORDER BY name

    You need to specify what object you are checking the...

  • RE: HELP: Select within select (looping through records)

    I have a select statement that selects a set of records from tables, as follows:

    select attrA from tableA inner join tableB on tableA.attrC = tableB.attrA where attrC =...

  • RE: multiple params for where condition ??

    Good article. Going in the bookmarks. Thanks for that.

  • RE: SQL Challenge - 'aggregating columns into grouped rows'

    You can use a function to get this working

    IF (SELECT OBJECT_ID('tempTable')) IS NOT NULL

    DROP TABLE tempTable

    GO

    CREATE TABLE tempTable (test int, test2 VARCHAR(10))

    INSERT INTO tempTable VALUES (1, 'Test')

    INSERT INTO tempTable VALUES...

  • RE: Zero fill (Format) a field.

    CREATE TABLE #temp (test INT)

    INSERT INTO #temp values (1111)

    INSERT INTO #temp values (22222)

    INSERT INTO #temp values (333333)

    INSERT INTO #temp values (4444444)

    INSERT INTO #temp values (55555555)

    INSERT INTO #temp values (666)

    SELECT REPLICATE('0',8-LEN(test))+CONVERT(VARCHAR,test)...

Viewing 15 posts - 151 through 165 (of 206 total)