deals2buy Posted November 14, 2012 Report Share Posted November 14, 2012 [quote name='Desamudhuru' timestamp='1352925669' post='1302796709'] Edi SQL 7.0 mida work cheyali baa... Chudali anni DTS mida vunatu vundi. [/quote] maree ghoram ga SQL 7.0 aa? nuvvu undedi which city mama? Link to comment Share on other sites More sharing options...
deals2buy Posted November 15, 2012 Report Share Posted November 15, 2012 [CODE] CREATE TABLE #QoTD ( WithOutDefault int, WithDefault varchar(25) DEFAULT 'default' ) --1 INSERT INTO #QoTD (WithOutDefault) VALUES (1) --2 INSERT INTO #QoTD (WithOutDefault, WithDefault) VALUES (2, NULL) --3 INSERT INTO #QoTD (WithOutDefault, WithDefault) VALUES (3,'DEFAULT') --4 INSERT INTO #QoTD (WithOutDefault, WithDefault) VALUES (4,DEFAULT) [/CODE] Which of the insert statements will use the default on column WithDefault? (select 2) DEFAULT ani okati untadani naku telvadu... Link to comment Share on other sites More sharing options...
deals2buy Posted November 15, 2012 Report Share Posted November 15, 2012 DECLARE @i int SET @i = 64; SET @i = @i ^ 2; SELECT @i AS Answer; ^ ante power kaada? deeni output enduku diff ga vastondi? evarain cheppandi koddiga Link to comment Share on other sites More sharing options...
deals2buy Posted November 15, 2012 Report Share Posted November 15, 2012 [b] Prevent Truncation of Dynamically Generated Results in SQL Server Management Studio[/b] http://www.mssqltips.com/sqlservertip/2795/prevent-truncation-of-dynamically-generated-results-in-sql-server-management-studio/ Link to comment Share on other sites More sharing options...
deals2buy Posted November 15, 2012 Report Share Posted November 15, 2012 [b] [url="http://www.sqlservercentral.com/blogs/mssqlfun/2012/11/07/how-to-save-deadlock-graph-events-as-xdl-file-in-sql-server-/"]How to save deadlock graph events as .xdl file in SQL Server ?[/url][/b] Link to comment Share on other sites More sharing options...
Desamudhuru Posted November 15, 2012 Report Share Posted November 15, 2012 [quote name='deals2buy' timestamp='1352926888' post='1302796916'] maree ghoram ga SQL 7.0 aa? nuvvu undedi which city mama? [/quote] Edi in waukegan mama. USA BlueBook client. Prastutam 2005 mida working. Next SQL 7.0 mida work cheyali. Link to comment Share on other sites More sharing options...
deals2buy Posted November 15, 2012 Report Share Posted November 15, 2012 [quote name='Desamudhuru' timestamp='1353001784' post='1302801257'] Edi in waukegan mama. USA BlueBook client. Prastutam 2005 mida working. Next SQL 7.0 mida work cheyali. [/quote] ok ... adendi 2005 nundi malli back enduku pothunnaru? Link to comment Share on other sites More sharing options...
deals2buy Posted November 16, 2012 Report Share Posted November 16, 2012 [b] Random Number Generator Script – SQL Query[/b] There are many methods to generate random number in SQL Server. [CODE] Method 1 : Generate Random Numbers (Int) between Rang ---- Create the variables for the random number generation DECLARE @Random INT; DECLARE @Upper INT; DECLARE @Lower INT ---- This will create a random number between 1 and 999 SET @Lower = 1 ---- The lowest random number SET @Upper = 999 ---- The highest random number SELECT @Random = ROUND(((@Upper - @Lower -1) * RAND() + @Lower), 0) SELECT @Random Method 2 : Generate Random Float Numbers SELECT RAND( (DATEPART(mm, GETDATE()) * 100000 ) + (DATEPART(ss, GETDATE()) * 1000 ) + DATEPART(ms, GETDATE()) ) Method 3 : Random Numbers Quick Scripts ---- random float from 0 up to 20 - [0, 20) SELECT 20*RAND() -- random float from 10 up to 30 - [10, 30) SELECT 10 + (30-10)*RAND() --random integer BETWEEN 0 AND 20 - [0, 20] SELECT CONVERT(INT, (20+1)*RAND()) ----random integer BETWEEN 10 AND 30 - [10, 30] SELECT 10 + CONVERT(INT, (30-10+1)*RAND()) Method 4 : Random Numbers (Float, Int) Tables Based with Time DECLARE @t TABLE( randnum float ) DECLARE @cnt INT; SET @cnt = 0 WHILE @cnt <=10000 BEGIN SET @cnt = @cnt + 1 INSERT INTO @t SELECT RAND( (DATEPART(mm, GETDATE()) * 100000 ) + (DATEPART(ss, GETDATE()) * 1000 ) + DATEPART(ms, GETDATE()) ) END SELECT randnum, COUNT(*) FROM @t GROUP BY randnum Method 5 : Random number on a per row basis ---- The distribution is pretty good however there are the occasional peaks. ---- If you want to change the range of values just change the 1000 to the maximum value you want. ---- Use this as the source of a report server report and chart the results to see the distribution SELECT randomNumber, COUNT(1) countOfRandomNumber FROM ( SELECT ABS(CAST(NEWID() AS binary(6)) %1000) + 1 randomNumber FROM sysobjects) sample GROUP BY randomNumber ORDER BY randomNumber [/CODE] Link to comment Share on other sites More sharing options...
deals2buy Posted November 16, 2012 Report Share Posted November 16, 2012 [b] Retrieving Random Rows from Table Using NEWID()[/b] [color=blue]USE [/color][color=black]AdventureWorks2012 GO[/color] [color=green]-- Method 1[/color] [color=blue]SELECT TOP [/color][color=black]100 [/color][color=gray]*[/color] [color=blue]FROM [/color][color=black]Sales.SalesOrderDetail[/color] [color=blue]ORDER BY [/color][color=magenta]NEWID[/color][color=gray]()[/color] [color=black]GO[/color] [color=green]-- Method 2[/color] [color=blue]SELECT TOP [/color][color=black]100 [/color][color=gray]*[/color] [color=blue]FROM [/color][color=black]Sales.SalesOrderDetail[/color] [color=blue]ORDER BY [/color][color=black]CHECKSUM[/color][color=gray]([/color][color=magenta]NEWID[/color][color=gray]())[/color] [color=black]GO[/color] [img]http://www.pinaldave.com/bimg/newidrandom.jpg[/img] You will notice that using NEWID() in the ORDER BY will return random rows in the result set. How many of you knew this trick? You can run above script multiple times and it will give random rows every single time. Link to comment Share on other sites More sharing options...
9Pardhu Posted November 16, 2012 Author Report Share Posted November 16, 2012 While restoring Fresh 100+ gb file, I got this following error and restoring process stopped. Any one know this error? Msg 3202, Level 16, State 1, Line 1 Write on "???" failed: 170(The requested resource is in use.) Msg 3013, Level 16, State 1, Line 1 RESTORE DATABASE is terminating abnormally. Link to comment Share on other sites More sharing options...
deals2buy Posted November 16, 2012 Report Share Posted November 16, 2012 [b] Generating SubTotals using GROUPING[/b] http://www.sqlservercentral.com/articles/Groouping/70023/ Link to comment Share on other sites More sharing options...
calmandquiet Posted November 16, 2012 Report Share Posted November 16, 2012 GP Link to comment Share on other sites More sharing options...
deals2buy Posted November 16, 2012 Report Share Posted November 16, 2012 [quote name='9pardhu' timestamp='1353077296' post='1302806432'] While restoring Fresh 100+ gb file, I got this following error and restoring process stopped. Any one know this error? Msg 3202, Level 16, State 1, Line 1 Write on "???" failed: 170[b][color=#ff0000](The requested resource is in use.)[/color][/b] Msg 3013, Level 16, State 1, Line 1 RESTORE DATABASE is terminating abnormally. [/quote] that itself explains kadaa Link to comment Share on other sites More sharing options...
9Pardhu Posted November 16, 2012 Author Report Share Posted November 16, 2012 Which Resource is in Use? Storage one or Login Account or ??? edi use lo vundi.. I tried killing some of the spids which is accessing particular one.. But no effect. Link to comment Share on other sites More sharing options...
deals2buy Posted November 16, 2012 Report Share Posted November 16, 2012 [quote name='9pardhu' timestamp='1353077894' post='1302806485'] Which Resource is in Use? Storage one or Login Account or ??? edi use lo vundi.. I tried killing some of the spids which is accessing particular one.. But no effect. [/quote] The file u r trying to restore is in use anukuntunna... Try killing all the spids that are using that and try again.. Link to comment Share on other sites More sharing options...
Recommended Posts