Viewing 15 posts - 796 through 810 (of 1,491 total)
There is a large section on Service Broker in BOL (Books Online).
January 19, 2011 at 10:38 am
You can get the same effect by creating a QUEUE and using Service Broker.
January 19, 2011 at 9:43 am
Maybe you want something like:
WHERE [state] =
CASE
WHEN @statefilter = 2
THEN 'CA'
WHEN @statefilter = 3 AND [state] = 'CA'
THEN 'ZZ' -- junk value
ELSE [state]
END
January 19, 2011 at 7:29 am
Could be network problems.
I would be inclined to to the backups onto a local share and then have them copied to the other server.
January 19, 2011 at 3:54 am
To pass a table variable you have to create a type and define the table as the type.
What you are trying to do will not work as table variables can...
January 19, 2011 at 3:52 am
You appear to selecting not merging.
Try something like:
SET ANSI_NULLS, QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE dbo.GetTblGUID
@Address nvarchar(255)
,@GUID uniqueidentifier OUTPUT
AS
DECLARE @GUIDs TABLE
(
[GUID] uniqueidentifier NOT NULL
);
INSERT INTO Tbl
OUTPUT inserted.[GUID] INTO @GUIDs
SELECT NEWID(), @Address
WHERE NOT EXISTS
(
SELECT...
January 18, 2011 at 10:15 am
You may be best to do it all in one statement to avoid potential concurrency problems.
Something like:
;WITH DivRows
AS
(
SELECT RowNo, Division, UserName
...
January 13, 2011 at 3:10 am
Add computed columns:
ALTER TABLE dbo.PCList
ADD PCNamePreFix
AS
(
CAST
(
CASE PATINDEX('%[0-9]%', PCName)
WHEN 1 THEN ''
WHEN 2 THEN LEFT(PCName, 1)
WHEN 3 THEN LEFT(PCName, 2)
ELSE LEFT(PCName, 3)
END
AS varchar(3)
)
) --PERSISTED
, PCNameNumber
AS
(
CAST
(
CASE PATINDEX('%[0-9]%', PCName)
WHEN 0 THEN...
January 12, 2011 at 9:46 am
harinerella (1/4/2011)
Simple solution could be applying UPDLOCK at the time of selection, which will not allow other sessions to lock the same row.
You also have to apply a key range...
January 4, 2011 at 3:49 am
Try:
SELECT usernumber
FROM tblaccess
WHERE readernumber IN (1,2,3,4,5,6)
GROUP BY A.usernumber
HAVING
-- Max entry accessid (assuming accessid is an IDENTITY. If not use accessdatetime.
MAX(CASE WHEN readernumber IN (1,2,3) THEN A.accessid ELSE 0 END)
...
December 16, 2010 at 5:12 am
Assuming your DDL is something like:
CREATE TABLE tblaccess
(
accessid int IDENTITY NOT NULL
PRIMARY KEY
,accessdatetime datetime
,usernumber int NOT NULL
,readernumber int NOT NULL
)
CREATE TABLE readernumbers
(
readernumber int NOT NULL
PRIMARY KEY
,readerSet varchar(5)
CHECK (readerSet IN ('entry',...
December 15, 2010 at 10:01 am
If the table is heavily used, you might have problems in obtaining a schema lock to do the sp_rename.
You may have to look at doing an upsert and changing the...
December 14, 2010 at 4:48 am
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
Viewing 15 posts - 796 through 810 (of 1,491 total)