Forum Replies Created

Viewing 15 posts - 31 through 45 (of 48 total)

  • RE: concatenate ' and % in like estatement

    Solved!

    The trick is generate % with char function: 😀

    PROCEDURE search(@name nvarchar(20)=null)

    select * from TableName

    where FirstName like N'' + char(37) + @name + char(37) + ''

    note: char(37) = %

    ___________________________________
    Computer Enterprise Masoud Keshavarz
    I don't care about hell.
    If I go there I've played enough Diablo to know how to fight my way out.

  • RE: concatenate ' and % in like estatement

    kapil_kk (8/5/2013)

    Then change the datatype VARCHAR to NVARCHAR

    I changed my datatype from VARCHAR To NVARCHAR

    But N character is critical in none English statements.

    I need a query to generate this:

    N'%?????%'

    Your query...

    ___________________________________
    Computer Enterprise Masoud Keshavarz
    I don't care about hell.
    If I go there I've played enough Diablo to know how to fight my way out.

  • RE: concatenate ' and % in like estatement

    Thank you very much but 'N' character in condition is critical because i search none English.

    I need something like:

    DECLARE @name VARCHAR(20) = '?????'

    SELECT * FROM Person.Person WHERE LastName LIKE N'%'+@name+'%'

    Result...

    ___________________________________
    Computer Enterprise Masoud Keshavarz
    I don't care about hell.
    If I go there I've played enough Diablo to know how to fight my way out.

  • RE: What is # in first letter of table names?

    Alan.B (7/9/2013)


    HanShi mentioned local and global temp tables. You don't see this as often but a global temp table has two numbers signs in front of it like so: ##temptable....

    ___________________________________
    Computer Enterprise Masoud Keshavarz
    I don't care about hell.
    If I go there I've played enough Diablo to know how to fight my way out.

  • RE: How Stored Procedure determine to return a value?

    Thanks Jeff Moden, I'm your fan in this forum.

    By the way, what you've posted isn't a stored procedure. It's just a script

    You wrote this Stored Procedure in one of your...

    ___________________________________
    Computer Enterprise Masoud Keshavarz
    I don't care about hell.
    If I go there I've played enough Diablo to know how to fight my way out.

  • RE: How Stored Procedure determine to return a value?

    Thank you very much.

    I changed my Stored Procedure to this:

    DECLARE @MyString NVARCHAR(3);

    SELECT CASE

    WHEN 1 = 1

    ...

    ___________________________________
    Computer Enterprise Masoud Keshavarz
    I don't care about hell.
    If I go there I've played enough Diablo to know how to fight my way out.

  • RE: What is # in first letter of table names?

    Thank you every one.

    @HanShi

    If you put a double # sign in front of the table name, the table will also be created in [tempdb] database and is called a global...

    ___________________________________
    Computer Enterprise Masoud Keshavarz
    I don't care about hell.
    If I go there I've played enough Diablo to know how to fight my way out.

  • RE: Difference between Cluster and Index

    Thank you everyone.

    This article helped me to understand concept of Indexes.

    https://www.simple-talk.com/sql/learn-sql-server/sql-server-index-basics/%5B/url%5D

    For a further step I must use them in practice.

    Now I see in this forum there are really professional guys...

    ___________________________________
    Computer Enterprise Masoud Keshavarz
    I don't care about hell.
    If I go there I've played enough Diablo to know how to fight my way out.

  • RE: a query like factorial

    Sorry for replying after so long, but I found an easy solution for this and I liked to share it here, perhaps it help someone in future.

    DECLARE @factorial int

    SET @factorial...

    ___________________________________
    Computer Enterprise Masoud Keshavarz
    I don't care about hell.
    If I go there I've played enough Diablo to know how to fight my way out.

  • RE: Use MAX in insert query

    GilaMonster (5/6/2013)


    INSERT INTO TableName (ID,Value)

    SELECT coalesce(MAX(ID),0) + 1, 'something' FROM TableName;

    Thank you, hence this statement is not allowed:

    INSERT INTO TableName (Value1,value2)

    values(

    select value1 from table1,

    select value2 from table2

    )

    Instead you must join...

    ___________________________________
    Computer Enterprise Masoud Keshavarz
    I don't care about hell.
    If I go there I've played enough Diablo to know how to fight my way out.

  • RE: Use MAX in insert query

    Well, found a solution

    Declare @i int;

    Select @i = coalesce(MAX(ID),0) + 1 FROM TableName;

    INSERT INTO TableName (ID,Value)

    VALUES (@i, 'something')

    If you think there would be any better way to do this please...

    ___________________________________
    Computer Enterprise Masoud Keshavarz
    I don't care about hell.
    If I go there I've played enough Diablo to know how to fight my way out.

  • RE: a query like factorial

    Thank you Horatiu, mickyT, Erin Ramsay for your time and help.

    @SQLRNNR

    May you help me to trace your code on paper please?

    Im a newbie and im not sure how does it...

    ___________________________________
    Computer Enterprise Masoud Keshavarz
    I don't care about hell.
    If I go there I've played enough Diablo to know how to fight my way out.

  • RE: On Error Do Next Query

    Thank you very much 🙂

    ___________________________________
    Computer Enterprise Masoud Keshavarz
    I don't care about hell.
    If I go there I've played enough Diablo to know how to fight my way out.

  • RE: Display two fields of two UNRELATED tables WITHOUT crossjoin

    GilaMonster (2/5/2013)


    In this particular case, since you want the two counts...

    SELECT q1, q2 FROM

    (SELECT Count(a.PK) as q1 FROM Table1 as a) t1,

    (SELECT Count(b.PK) as q2 FROM Table2 as b)...

    ___________________________________
    Computer Enterprise Masoud Keshavarz
    I don't care about hell.
    If I go there I've played enough Diablo to know how to fight my way out.

  • RE: WHERE [column name] NOT IN check after each insert

    Thank you very much.

    I couldn't find thanks button any where.

    I'm really really thank you. It worked perfectly.

    It solved my problem but I want to learn how does it works.

    I will...

    ___________________________________
    Computer Enterprise Masoud Keshavarz
    I don't care about hell.
    If I go there I've played enough Diablo to know how to fight my way out.

Viewing 15 posts - 31 through 45 (of 48 total)