Viewing 15 posts - 811 through 825 (of 1,494 total)
You can often get away with one generic exception handler.
SET ANSI_NULLS, QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE dbo.ExceptionHandler
AS
SET NOCOUNT ON
DECLARE @ErrorNumber int = ERROR_NUMBER()
,@ErrorSeverity int = ERROR_SEVERITY()
,@ErrorState int = ERROR_STATE()
,@ErrorProcedure nvarchar(126) = ERROR_PROCEDURE()
,@ErrorLine...
December 14, 2010 at 4:32 am
Something like the following may be worth a try:
SELECT o_num
INTO #orders
FROM orders
WHERE o_type IN (9, 30)
AND trn_id IN (24, 45, 25, 0)
ALTER TABLE #orders
ADD PRIMARY KEY (o_num)
-- This assumes that...
November 24, 2010 at 10:19 am
The sp_executesql procedure works like a dynamic SP so you can only pass values, and not object names, as parameters.
To guard against SQL injection you can validate column names against...
November 23, 2010 at 8:43 am
Master.dbo.spt_values is alright for quick queries but for production code I would be inclinded to generate a Numbers table in the relevant DB.
November 23, 2010 at 8:03 am
WHERE N.type = 'P' AND N.number BETWEEN 0 AND 29
November 22, 2010 at 8:30 am
It is best to search on a range so that there are no functions on J.JobTimeStamp, making it SARGable:
-- either
SELECT DATEADD(d, DATEDIFF(d, 0, CURRENT_TIMESTAMP), - N.number) AS MissingDate
FROM [master].dbo.spt_values N
WHERE...
November 22, 2010 at 5:08 am
Given your table definition, this should generate some usable test data:
SELECT TOP (100)
'UNION ALL SELECT '
+ CAST(ID AS varchar(20)) + ' AS ID,'
+ CAST(MainID AS varchar(20)) + ' AS MainID,'
+...
November 16, 2010 at 10:54 am
C# Screw (11/5/2010)
simply locking the row would have been fine.
This I could do in my FoxPro days, but in SQL it seems that at least a page locked.
For example...
November 5, 2010 at 12:25 pm
Here is a CLR function which could be used in Sergiy's code:
http://www.pluralsight-training.net/community/blogs/dan/archive/2006/07/27/32597.aspx
or if the operators are simple enough, just use the XML capability.
November 5, 2010 at 7:21 am
WHERE ColumnA LIKE
CASE
WHEN @Type = 'TWO' THEN N'%' + N' 20-' + N'%'
ELSE N'%' + N' [3-4]0-' + N'%'
END
November 2, 2010 at 10:38 am
GSquared (10/28/2010)
Not a good plan. What if you end up with concurrent inserts both picking 12 as the next value? Then both succeed.
It is a very good plan...
October 29, 2010 at 3:31 am
The following gives an example of the sort of code you need to be careful with:
http://en.wikipedia.org/wiki/Snapshot_isolation
As a concrete example, imagine V1 and V2 are two balances held by a single...
October 28, 2010 at 10:31 am
While snapshot isolation can be very useful, you should google 'write skew anomolies', check your code and do a lot of testing.
October 28, 2010 at 10:00 am
The classic way around this is to add a nonclustered index for the FK check to use.
Something like the following should work:
ALTER TABLE test1
ADD CONSTRAINT uq_test1 UNIQUE NONCLUSTERED (a)
October 28, 2010 at 9:50 am
ady.foot7970 (10/27/2010)
I want to limit the number of Cartwall titles to 12 and this need a trigger to enforce this in the database.
You can enforce this without triggers by...
October 28, 2010 at 8:51 am
Viewing 15 posts - 811 through 825 (of 1,494 total)