views:

256

answers:

1

I have a dynamic query in which I want to concatenate uniqueidentifier, but + and & operators are not supporting this, is there a way I can concatenate uniqueidentifier to a dynamic string. Any sample or any help in this regard will be highly appricated.

+1  A: 

Have you tried casting or converting to a string first, then concating?

CAST(NEWID() AS NVARCHAR(36))
Frank Krueger
i tried this it is not working, giving incorrect syntax near cast, or convert if im converting
Yaser Ahmed
@Yaser: "SELECT CAST(NEWID() AS NVARCHAR(36))". Please try and think for yourself.
gbn
Sorry Dear friends my where condition is WHERE (CreatedBy= CAST(@p_CreatedBy AS NVARCHAR(100)) )here @CreatedBy is a uniqueidentifieri even tried converting it, not getting any result.Please help
Yaser Ahmed
@Yaser CAST() may be formatting the Guid differently than your "CreatedBy" column. Run both versions by hand and check that the strings follow the same format. If not, then convert the other "CreatedBy" to a Guid and compare Guids instead.
Frank Krueger
it might be the problem, but how do i do that
Yaser Ahmed