Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ShyamRemella
Starting Member
1 Post |
Posted - 2003-07-16 : 03:19:05
|
| [Problem Code]DECLARE @I NVARCHAR(50)DECLARE @J NVARCHAR(50)DECLARE @R NVARCHAR(50)DECLARE @R1 NVARCHAR(50)SET @R1=4SET @I='1'SET @J='@R'SET @R= @J + @IPRINT @R[My Query]Here @R is printing '@R1',but I wanted to print @R1 value. How can I do this?Regards,R.Shyam |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2003-07-16 : 03:31:47
|
| I'm not sure that what you want to do is achievable. You would almost certainly have to use dynamic SQL to do it if it is.Something likeDECLARE @I NVARCHAR(50) DECLARE @J NVARCHAR(50) DECLARE @R NVARCHAR(50) DECLARE @R1 NVARCHAR(50) declare @mys varchar(20)SET @R1=4 SET @I='1' SET @J='@R' SET @R= @J + @I set @mys = '..sp_executesql SELECT ' + @J + @I +''exec (@mys)But not exactly that as the context is wrong. (R1 is not declared for that statement).You may be better off holding these pieces of data in normalised tables.-------Moo. :)Edited by - mr_mist on 07/16/2003 03:48:31 |
 |
|
|
|
|
|