Forum Replies Created

Viewing 15 posts - 241 through 255 (of 346 total)

  • RE: concatenate strings from a select

    Alternatively you could append the string in the select statement...

    DECLARE @tk_total Varchar(2000)

    SET @tk_total = ''

    SELECT @tk_total = @tk_total +

       CASE Len(@tk_total) WHEN 0 THEN '' ELSE

        CASE WHEN tk_number IS...

  • RE: SP wildcard

    something like this??

    use pubs

    DECLARE @au_ID Varchar(20)

    DECLARE @au_lname Varchar(100)

    SET @au_ID = '172-32-1176'

    -- SET @au_ID = NULL

    SET @au_lname = 'White'

    -- SET @au_lname = NULL

    SELECT * FROM dbo.authors WHERE

    au_id = CASE WHEN @au_id...

  • RE: How to have no error message ?

    There might be a difference in the database options set on the test database and the production database which are suppressing the error messages on the test database...to check if...

  • RE: Excluding duplicated columns after join

    I don't think there's any easy way to generally identify and remove duplicated column names that result from a join. If you use a "SELECT * " while joining two...

  • RE: INFORMATION_SCHEMA and identity columns

    you could use the COLUMNPROPERTY function to check if a column is an identity column or not...

    SELECT

    COLUMN_NAME,

    DATA_TYPE,

    CASE COLUMNPROPERTY (OBJECT_ID('<TableName>'),COLUMN_NAME ,'IsIdentity') WHEN 1 THEN 'Identity Column' ELSE '' END Identity_Column

    FROM...

  • RE: Permissions to execute SET IDENTITY_INSERT

    Razvan is right...my solution won't work...(from next time I'll try to test things out before posting..

  • RE: Permissions to execute SET IDENTITY_INSERT

    since execute permissions to SET IDENTITY_INSERT default to sysadmin server role and db_owner and db_ddladmin db roles and the object owner if User2 is not part of any of these...

  • RE: Returning a RID

     

    This article should help in deleting duplicates from your table:

    http://www.sql-server-performance.com/rd_delete_duplicates.asp

  • RE: Accessing the Description property of a field

    these descriptions are stored in the sysproperties system table (don't know if they are also stored in any INFORMATION_SCHEMA view) along with the object id of the table...

    this query should...

  • RE: Getting error message

    might be a problem with the int variables (@BusSrcId, @AdminId int, @FirmId int, @DaysOverdueRange) being used to generate the string...

    try to CAST the int values as varchar and see if that...

  • RE: Update Query

    You could alternatively write two update statements..

    UPDATE #tbl SET

     #tbl.Amount = #tbl.Amount + (SELECT Sum(T.Amount) FROM #tbl T WHERE T.RowNo < #tbl.RowNo)

    WHERE #tbl.Type = 'S'

    UPDATE #tbl SET

     #tbl.Amount = #tbl.Amount...

  • RE: Change word that r in upper like the Excel function proper

    The scripts section of this site have lots of stuff for such situations...here are two scripts that do the "neat" casing...(in the T-SQL Aids scripts section)

    http://www.sqlservercentral.com/scripts/contributions/981.asp

    http://www.sqlservercentral.com/scripts/contributions/890.asp

  • RE: DataFiles

    Hi Alex,

    the sysindexes, sysfiles and sysfilegroups system tables can be queried to get this info...

    SET NOCOUNT ON

    Declare @TabID int

    Declare @TabName sysname

    Create table #TabLocations(TableName sysname,FileGroupName sysname,LogicalFileName nchar(128),FilePath nchar(260))

    Declare TabCUR CURSOR FOR

     Select id,name...

  • RE: Whats Wrong?

    You just need to make it SQL Server specific..

    create table users

    (

    user_id int  not null identity primary key,

    username varchar(15) not null,

    password varchar(8) not...

  • RE: How to Execute quary in store procedure

    Hi,

    This should work...

    alter procedure mype

    as

      DECLARE @a varchar(200)

      set @a= 'create table #mytable

                 ( itemcode varchar(15),

                   itemname varchar(50),

                   unitname varchar(15),

                   unitprice money

                  )'

      exec (@a) --...

Viewing 15 posts - 241 through 255 (of 346 total)