Viewing 15 posts - 61 through 75 (of 78 total)
Be sure on what server and db do you execute "select ... into" query. Also specify schema like "select ... into dbo.MyTable...".
After that, when you want to query created table...
August 7, 2012 at 12:38 am
WoW! When I asked for testing, I didn't think that it will turn into a kind of contest =)
Here is one more for uint.
PRINT '========== ??? ========================'
SET STATISTICS TIME ON;
DECLARE...
August 7, 2012 at 12:22 am
Cadavre,
Thx for the testing scripts! Especially pointing a bug with replace function (closed as by design).
I have quite similar results
========== SomewhereSomehow ===========================================
SQL Server Execution Times:
CPU time...
August 6, 2012 at 4:18 am
Cool!!! 4 ways to solve the problem! Definitly all go to my KB.
CELKO's - is the fastest or isn't it? Who will make a proof test?
ps
CELKO,
Are you a Joe Celko,...
August 5, 2012 at 8:33 am
Yes, because it trims all the right spaces. So maybe you should consider to change data type to varchar.
Good luck!
August 5, 2012 at 8:16 am
I could hardly understand your question.
Could you please provide table structure, sample data, your query as whole, the results you get and the results you want?
August 5, 2012 at 7:45 am
You may disable constraint like that
alter table dbo.T4 nocheck constraint fk_T4_sid
and do what you want, but, be aware of performance problems. I blogged about it here[/url] (unfortunatelly it is only...
August 5, 2012 at 7:32 am
CAST and CONVERT (Transact-SQL)
Is there any problem with that?
August 5, 2012 at 6:59 am
gerard-593414 (8/5/2012)
I use following:
DECLARE @MYVAR Char(1000) = 'INITIAL'
if Conditon 1
SET @MYVAR = @MYVAR + ' ABC'
If Condition 2
...
August 5, 2012 at 6:57 am
CELKO,
Good idea, interesting approach! Smth tell's me that it would be also the fastest way of doing this!
August 5, 2012 at 1:54 am
XMLSQLNinja,
Using the same logic. Yor solution will not work if there will be 51 digits.
Try to understand - my solution was intended to work only with int (and 999 999...
August 4, 2012 at 12:10 am
No, you don't need a cursor, you may write it directly in query
update dbo.tblgas01g4c40
set DailyConsumption = convert(float,Consumption)/convert(float,FindDiffRead)
where FindDiffRead<>0
This will update all the rows in dbo.tblgas01g4c40, by setting to the column...
August 3, 2012 at 6:21 am
When you asking about alternate solution you, do mean funtctional equivalent? you may use case+group by instead of pivot, and cross apply instead of unpivot. You may also check out...
August 3, 2012 at 5:22 am
You are trying to devide integer by integer, the result will be also integer.
To get float you should first convert your arguments to float like this, convert(float,@integer1)/convert(float,@integer2).
Btw, remember, that float...
August 3, 2012 at 4:59 am
Here is my solution
declare @i int = 985;
with nums(n) as(select n from (values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10))nums(n))
select sum(convert(int,substring(convert(varchar(10),@i),n,1)))
from nums where n <= len(convert(varchar(10),@i))
August 3, 2012 at 12:22 am
Viewing 15 posts - 61 through 75 (of 78 total)