Friday, March 6, 2015

finding the sum of cumulative as per daywise

Some idea


CREATE TABLE #t (c1 int,c VARCHAR(10))



INSERT INTO #t VALUES (20,'2*8')





DECLARE @formula varchar (5000)

DECLARE @val varchar (5000)

SET @formula = (select c from #t)

SET @val = (select c1 from #t)





DECLARE @var VARCHAR(100);

SET @var = 'N' + '''' + 'select '+@val+'-'+@formula + '''';

EXEC ('EXEC sp_executesql ' + @var);



---returns 4 (20-16)



Best Regards,Uri Dimant SQL Server MVP, http://ift.tt/1iQ9JkR



MS SQL optimization: MS SQL Development and Optimization

MS SQL Consulting: Large scale of database and data cleansing

Remote DBA Services: Improves MS SQL Database Performance

SQL Server Integration Services: Business Intelligence


No comments:

Post a Comment