﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2012 / SQL Server 2012 -  T-SQL </title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 24 May 2012 12:57:10 GMT</lastBuildDate><ttl>20</ttl><item><title>Change sequence schema</title><link>http://www.sqlservercentral.com/Forums/Topic1302982-3077-1.aspx</link><description>Hi all,I have some sequences and I want to change their schmas. How can I perform this action without drop and recreating (because of not changing current value) ?</description><pubDate>Sat, 19 May 2012 00:14:46 GMT</pubDate><dc:creator>farax_x</dc:creator></item><item><title>Assistance For Script</title><link>http://www.sqlservercentral.com/Forums/Topic1301074-3077-1.aspx</link><description>Hi What I am trying to do is do a calculation based on the previous records calculated value.What I though may work is not as think buffers prior.B is the latest records, A is the previous record. the trick here is how does one comit the the row then use it in the next one, without a cursorSample ScriptUpdate bset b.run_daily_avg_consum = cast(a.run_daily_avg_consum as decimal(15,5)) *.7 + b.Daily_avg_Consumption *.3From [Stage1W_Dim_Readings] a, [Stage1W_Dim_Readings] bWhere a.pod_no = b.pod_no and a.Read_Seq_Pod = b.Read_Seq_Pod-1Sample Excel Dump attached. Please can some-one give some suggestions.</description><pubDate>Wed, 16 May 2012 08:22:44 GMT</pubDate><dc:creator>ljmack00</dc:creator></item><item><title>Sorting Union</title><link>http://www.sqlservercentral.com/Forums/Topic1294469-3077-1.aspx</link><description>Hi all,I'm having a bit of trouble trying to order the first query in a union join.  I would like to select 2 records from a larger selection to display at the top of my results &amp; then the remaining results show underneath.Here is a cut down version of what i'm trying to do:[b]CREATE TABLE Entries(entriesID INT IDENTITY(1,1) NOT NULL,name VARCHAR(20) NOT NULL,packageLevel TINYINT NOT NULL)INSERT INTO Entries (name,packageLevel) VALUES ('aa',0)INSERT INTO Entries (name,packageLevel) VALUES ('bb',1)INSERT INTO Entries (name,packageLevel) VALUES ('cc',1)INSERT INTO Entries (name,packageLevel) VALUES ('dd',1)INSERT INTO Entries (name,packageLevel) VALUES ('ee',1)INSERT INTO Entries (name,packageLevel) VALUES ('ff',1)INSERT INTO Entries (name,packageLevel) VALUES ('gg',1)INSERT INTO Entries (name,packageLevel) VALUES ('hh',1)INSERT INTO Entries (name,packageLevel) VALUES ('ii',0)INSERT INTO Entries (name,packageLevel) VALUES ('jj',0)INSERT INTO Entries (name,packageLevel) VALUES ('kk',0)INSERT INTO Entries (name,packageLevel) VALUES ('ll',0)INSERT INTO Entries (name,packageLevel) VALUES ('mm',0)INSERT INTO Entries (name,packageLevel) VALUES ('nn',0)INSERT INTO Entries (name,packageLevel) VALUES ('oo',0)INSERT INTO Entries (name,packageLevel) VALUES ('pp',0)INSERT INTO Entries (name,packageLevel) VALUES ('qq',0)INSERT INTO Entries (name,packageLevel) VALUES ('rr',0)INSERT INTO Entries (name,packageLevel) VALUES ('ss',0)CREATE PROCEDURE usp_getEntryASSELECT TOP 2 	entriesID	,name	,packageLevel	,NEWID() AS [RANDOM] FROM EntriesWHERE packageLevel = 1 UNIONSELECT	entriesID	,name	,packageLevel	,NEWID() AS [RANDOM] FROM EntriesWHERE packageLevel &amp;lt;&amp;gt; 1ORDER BY packageLevel desc, RANDOMEXEC usp_getEntry[/b]As you can see in the data the records bb,cc,dd,ee,ff,gg,hh all have a package level of 1.  I need to randomly select 2 of these to show at the top of the results.  But as the "Select top 2" happens before the "order by packageLevel desc, RANDOM" at the end of the query. It only ever randomises the top 2 records. bb &amp; cc.  If I could order an "Order by" to the first query that would be exactly what I want, unfortunately SQL does not alow me to do this.  Does anyone know of a better way to randomly select 2 (package level 1) records to display at the top of my results.  I hope this is clear.Darren</description><pubDate>Thu, 03 May 2012 04:28:30 GMT</pubDate><dc:creator>Darren Welch</dc:creator></item><item><title>MSSQL 2012 versus 2008...2000</title><link>http://www.sqlservercentral.com/Forums/Topic1259129-3077-1.aspx</link><description>I have been using the following syntax in prior versions and it worked, however when I try it in 2012 i get an error message.... raiserror 22004 'This is a test' 2012 errors out withIncorrect syntax near '22004'any ideas other than fixing all my raiserror commands to the new format. (lots of scripts/stored procedures/triggers)</description><pubDate>Tue, 28 Feb 2012 13:42:22 GMT</pubDate><dc:creator>roy.tollison</dc:creator></item><item><title>Regular expression in T-sql</title><link>http://www.sqlservercentral.com/Forums/Topic1286617-3077-1.aspx</link><description>how do we use Regular expressions in T-sql...Do we need to deploy the assemblies to sql server???</description><pubDate>Thu, 19 Apr 2012 12:19:02 GMT</pubDate><dc:creator>PradeepVallabh</dc:creator></item><item><title>Fatal Exception error (SQL server 2012 Enterprise Evaluation Edition)</title><link>http://www.sqlservercentral.com/Forums/Topic1281439-3077-1.aspx</link><description>I am getting following error in SQL server 2012 enterprise evaluation edition (11.0 RTM).SqlDumpExceptionHandler: Process 7648 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.Any suggestion?</description><pubDate>Wed, 11 Apr 2012 05:12:28 GMT</pubDate><dc:creator>Ashish K Sinha</dc:creator></item><item><title>DATE and TIME Add issues in 2012.</title><link>http://www.sqlservercentral.com/Forums/Topic1279094-3077-1.aspx</link><description>So I was moving my DB from 2008 to 2012, and while restoring patches of our software, I came across this issue in one of the stored procs.DATE + TIME Add works good in SQL2008R2 Fails in SQL2012RC0[code="sql"]--WORKS IN 2008R2 ,2012 DECLARE @ESTDate DATE = '01/01/2012',@ESTime TIME(7) = '01:00 PM'SELECT CONVERT(DATETIME, @ESTDate, ( 108 ))+ @ESTime--WORKS IN 2008R2 ( DECLARE @ESTRecords TABLE(    ESTime TIME(7) NOT NULL,	ESTDate DATE NOT NULL,    ESTDateTime AS ( CONVERT(DATETIME, ESTDate, ( 108 )) + ESTime ) PERSISTED)INSERT INTO @ESTRecords (ESTime,ESTDate)VALUES( '12:00 PM','12/31/2012')SELECT * FROM @ESTRecords--DOESNOT WORK IN 2012RC0 ( DECLARE @ESTRecords TABLE(    ESTime TIME(7) NOT NULL,	ESTDate DATE NOT NULL,    ESTDateTime AS ( CONVERT(DATETIME, ESTDate, ( 108 )) + ESTime ) PERSISTED)INSERT INTO @ESTRecords (ESTime,ESTDate)VALUES( '12:00 PM','12/31/2012')SELECT * FROM @ESTRecords[/code]Any Inputs? Suggestions. Is this happening to others as well?</description><pubDate>Thu, 05 Apr 2012 12:49:11 GMT</pubDate><dc:creator>JackIntheBox</dc:creator></item><item><title>Finding time between 2 dates considering working hours</title><link>http://www.sqlservercentral.com/Forums/Topic1267334-3077-1.aspx</link><description>Hi All. I have a scenario in which i need to calculate the time consumed by the user to do a task. suppose Start Time is : 2012-03-14 10:00 amand End Time is : 2012-03-15 10:amand working hours is 7 am to 2 pmthen result should be : 7 hours and not 24 hrs.I know i did to use DateDiff with case statement but i am not able to frame by T-SQL statements.Thanks.</description><pubDate>Thu, 15 Mar 2012 04:03:08 GMT</pubDate><dc:creator>jankhana</dc:creator></item></channel></rss>
