Meysam Tolouee
Meysam Tolouee

Reputation: 579

Is it possible to use a select statement as parameter of built-in function?

Here it is my Sql query:

Update  Accounting.ACNT.Book
    Set [No] = Case When A.IsAccType10 = 1 Then [No] - 5000000000 Else [No] + 4000000000 End,
        FullNo = Stuff(Stuff(FullNo, Len(FullNo) - 10, 2, '05'), 1, Len(FullNo) - 12, '????')
    From    @Temp A,
            [Master].dbo.ParentIDMap B
    Where   A.BookID = Book.ID And
            B.AccType = Cast(SubString(Book.OriginalAccNo, 2, 1) as Int) - 100 And
            B.BranchID = Book.BranchID

Can I use a select statement instead of '?????' as last parameter of Stuff function?

The query I need to replace with is:

Select  ParentFullNo
    From    [Master].dbo.ParentIDMap A
    Where   A.BranchID = Book.BranchID

Upvotes: 0

Views: 30

Answers (1)

Reg Edit
Reg Edit

Reputation: 6914

Yes, just put the query in parentheses ().

Upvotes: 1

Related Questions