Hi i am newbie to ms sql my problem is i am passing string as run time and getting the spaceid's for that user but below code is giving
user as output pls verify this code and send me
DECLARE @user VARCHAR(1000), @spaceid INT
DECLARE @s VARCHAR(1000), @r varchar(1000)
set @user ='cat'
set @spaceid =''
Set @s = 'select user from staging.dbo.site where user = ' + quotename(@spaceid,'''')
set @r = 'select country,state,city,fromdate,todate,url,cost from staging.dbo.' + quotename('myads' + cast(@spaceid as varchar(11)))
exec(@s)
exec(@r)
Thanx
user as output pls verify this code and send me
DECLARE @user VARCHAR(1000), @spaceid INT
DECLARE @s VARCHAR(1000), @r varchar(1000)
set @user ='cat'
set @spaceid =''
Set @s = 'select user from staging.dbo.site where user = ' + quotename(@spaceid,'''')
set @r = 'select country,state,city,fromdate,todate,url,cost from staging.dbo.' + quotename('myads' + cast(@spaceid as varchar(11)))
exec(@s)
exec(@r)
Thanx