Forum Replies Created

Viewing 15 posts - 1 through 15 (of 24 total)

  • RE: temp table (#) Vs Dynamic Table (@)

    ALZDBA is correct, both temp tables and tables variables needs to be stored in tempdb under some circumstances. However, there are some differences in relation to performance to when it...

  • RE: CREATE FUNCTION permission denied in database

    Your best bet would probably be to make the user dbo, however it depends on the permission requirements of your particular db.

    If you would like to grant the permissions explicitly...

  • RE: 3 part naming in the query

    The querey itself should work on 2008 as well. This may be a longshot, but have you checked the collation of your 2008-db so it's not case sensitive?

  • RE: Delete from the same table in mutiple databases

    Hi,

    No the actual DELETE-syntax is incorrect, furthermore you cannot pass object names (DBs, tables, etc.) as variables like that without using dynamic SQL.

    Try something as below:

    Declare

    @db_name nvarchar(50)

    DECLARE db_cursor CURSOR FOR...

  • RE: Select records form lasthour

    WHERE [DATE] >= DATEADD(HOUR, - 1, GETDATE())

  • RE: SQL Server Collation Questions

    Hi David,

    Wouldn't describe it as a real issue, but obviously you would have to use COLLATE when joining string data in temp tables with string data in user DBs.

  • RE: Stored procedure with parameters not working

    No problems.

    I don't know exactly what your planned usage is, however if you'd like to be protected against SQL injection you should consider using sp_executesql instead of EXECUTE.

  • RE: Stored procedure with parameters not working

    Hi,

    The error occurs because you're trying to use object names (tables, columns, etc.) in variables. In order to achieve what you want you need to use dynamic SQL.

    See the example...

  • RE: resume after error for primary key violation

    Hi ann, check books online for TRY...CATCH.

  • RE: Query slow

    For the query itself you might want to try something like

    DECLARE @TotalNumberOfUnits INT

    SELECT @TotalNumberOfUnits = COUNT(*) FROM Temp WHERE GUID=@GUID

    DECLARE @Res TABLE

    (

    Results SMALLINT PRIMARY KEY CLUSTERED,

    NumOcc INT

    )

    INSERT @Res

    (

    Results,

    NumOcc

    )

    SELECT

    Results,

    COUNT(*)

    FROM...

  • RE: complex query

    Hi there,

    I agree with Craig, the test data doesn't make sense.

    I'm assuming that submenuid corresponds to menuid and then the query would look something like below.

    -- Create testdata

    DECLARE @MasterTable TABLE...

  • RE: Split string to array

    Hi there,

    Create the function below, and then call it like SELECT * FROM F_ConvertStringToTable('1 Adam Rim Jessica Joel)', ' '):

    CREATE FUNCTION F_ConvertStringToTable

    (

    @List VARCHAR(MAX),-- Separerad lista av värden

    @Delimiter CHAR(1)-- Avgränsare/separator

    ) ...

  • RE: One-to-Many TSQL Query

    Or a CTE like below:

    ;WITH CUSTADDR

    AS

    (

    SELECT

    CUSTOMER_ID,

    ZIPCODE,

    ADDR,

    ROW_NUMBER() OVER(PARTITION BY CUSTOMER_ID, ZIPCODE ORDER BY SHIPPING_DATE DESC) AS RowNr

    FROM CUSTOMERADDRESS -- Your table

    )

    SELECT

    CUSTOMER_ID,

    ZIPCODE,

    ADDR

    FROM CUSTADDR

    WHERE RowNr = 1

  • RE: importing a pivot table data

    You're welcome. Glad I could help.

  • RE: UPDATE HELP

    The information on how to join the tables (on what values/columns) is still missing. Joining on the ADDR column, which would be my guess to would give no matches, so...

Viewing 15 posts - 1 through 15 (of 24 total)