Showing posts with label block. Show all posts
Showing posts with label block. Show all posts

Tuesday, March 20, 2012

Copy Database Wizard

I want to copy a database that is currently in use. The
DTS package fails if any user is connected. What command
would I issue to block all new connections to the
database? With new connections blocked and existing ones
finished, I should be able to copy the file the way the
wizard configures the package.Check out the ALTER DATABASE command in BOL
Nathan H.O.|||I assume that you are recommending something like:
ALTER DATABASE myDB SET SINGLE_USER
This command locks when the database is already in use.
>--Original Message--
>Check out the ALTER DATABASE command in BOL
>Nathan H.O.
>|||Not if you specify the proper ROLLBACK option.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"Dan" <deletethisprefixandthefirstperiod.cathedr@.dshs.wa.gov> wrote in message
news:2aab201c39270$35205650$a601280a@.phx.gbl...
> I assume that you are recommending something like:
> ALTER DATABASE myDB SET SINGLE_USER
> This command locks when the database is already in use.
>
> >--Original Message--
> >Check out the ALTER DATABASE command in BOL
> >
> >Nathan H.O.
> >

Sunday, February 12, 2012

Converting PL/SQL

I have an anonymous PL/SQL block that I'd like to Convert into T-Sql and im completly stumped on 2 things:
    What is the equvilent of a Cursor and how do I declare one?How do I declare an anonymous block?

my code wrote:


Declare
-- Type Declarations
Type ct_UConstr_Cur is REF CURSOR;
v_Begin Integer := 0;
v_End Integer := 0;
v_PageSize Integer :=0;
c_Data ct_UConstr_Cur;

Begin
v_PageSize := :PageSize;
v_Begin := ( v_PageSize * :PageNumber) - 1;
v_End := v_Begin + v_PageSize;

Open c_Data For
Select * from (
Select A, B, C, ROWNUM as RN from Foo;
) where RN >= v_Begin AND RN < v_End;
:cur := c_Data;
END;
/


JeffreyABecker wrote:

What is the equvilent of a Cursor and how do I declare one?


That would be ... a cursor. But how are you using it? If you're trying to pass output cursors from a stored procedure, just use result sets instead (i.e., SELECTs).

JeffreyABecker wrote:

How do I declare an anonymous block?


There is no such thing in T-SQL (thank Microsoft!). Just write your block of code. Here's a rough conversion of yours. Note we do not have ROWNUM in T-SQL. For an alternative, post the specific problem ...
DECLARE @.Begin INTEGER, @.End INTEGER, @.PageSize INTEGER
DECLARE @.Cur CURSOR
SET @.Begin = (@.PageSize * @.PageNumber) -1
SET @.Cur = CURSOR FOR SELECT * FROM A, B,C
OPEN @.Cur
... Do your ugly cursor stuff here, see BOL for how to ...
CLOSE @.Cur
|||

Try this link to test drive a conversion tool. Hope this helps.

http://www.downloadjunction.com/company/store/6265/index.html