Showing posts with label create. Show all posts
Showing posts with label create. Show all posts

Tuesday, March 27, 2012

deleting parameters in report designer

i have create a paramenters and use in the sql, but after i deleting it from
the sql statement, i still need to enter the paramenter in the PREVIEW.
i have check and clear the parameters clicking the "..." button but when i
check the properties of a table and set the expression, the parameter appears
in the "parameter" column.
i dun know if it is a bug or not...but thats strange
thanks for helping in advancehi all,
mmm i have solved the problem by deleting the <reportparamenter> tag in the
*.rdl code.
dont know if this is the formal method.
anyway, just share with you all.
"Jasonymk" wrote:
> i have create a paramenters and use in the sql, but after i deleting it from
> the sql statement, i still need to enter the paramenter in the PREVIEW.
> i have check and clear the parameters clicking the "..." button but when i
> check the properties of a table and set the expression, the parameter appears
> in the "parameter" column.
> i dun know if it is a bug or not...but thats strange
> thanks for helping in advance
>|||http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rscreate/htm/rcr_creating_structure_data_v1_72uk.asp
"Although report parameters are created automatically from query parameters,
you manage report parameters separately in the report layout view. Also, if
you change the name of a query parameter, or delete a query parameter, the
report parameter that corresponds to the query parameter is not
automatically changed or deleted. You can remove the report parameter by
using the Report Parameters dialog box."
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSUIREF/htm/f1_rsc_designer_v1_6h9v.asp
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Jasonymk" <Jasonymk@.discussions.microsoft.com> wrote in message
news:0B216069-4C8A-4404-AD60-D290AA1A0A8D@.microsoft.com...
>i have create a paramenters and use in the sql, but after i deleting it
>from
> the sql statement, i still need to enter the paramenter in the PREVIEW.
> i have check and clear the parameters clicking the "..." button but when i
> check the properties of a table and set the expression, the parameter
> appears
> in the "parameter" column.
> i dun know if it is a bug or not...but thats strange
> thanks for helping in advance
>|||In report layout, report menu, report parameters. Behind the scenes RS
creates the report parameters but they are two different things: the query
parameter and report parameter.
Bruce L-C
"Jasonymk" <Jasonymk@.discussions.microsoft.com> wrote in message
news:0B216069-4C8A-4404-AD60-D290AA1A0A8D@.microsoft.com...
> i have create a paramenters and use in the sql, but after i deleting it
from
> the sql statement, i still need to enter the paramenter in the PREVIEW.
> i have check and clear the parameters clicking the "..." button but when i
> check the properties of a table and set the expression, the parameter
appears
> in the "parameter" column.
> i dun know if it is a bug or not...but thats strange
> thanks for helping in advance
>

Deleting old servers still listed in Query Analyzer ????????

I can use the Client Network Utility (CNU) from SQL 2000 to create/delete
aliases.
But when I 1st run Query Analyzer (QA)... it shows a list of some old
servers we used to have... long ago.
How do I delete from that list?
(The old servers have already been removed from the CNU alias list... but
they seem to stay listed in QA forever.)
They have nothing to do with each other. Any registrations you did in QA or
EM you will have to manually delete them from the registrations by right
clicking and choosing Delete.
Andrew J. Kelly SQL MVP
""A_Michigan_User"" <Michigan_RE_M0VE@.ameritech.net> wrote in message
news:%23gKQ7lwOGHA.3944@.tk2msftngp13.phx.gbl...
>I can use the Client Network Utility (CNU) from SQL 2000 to create/delete
>aliases.
> But when I 1st run Query Analyzer (QA)... it shows a list of some old
> servers we used to have... long ago.
> How do I delete from that list?
> (The old servers have already been removed from the CNU alias list... but
> they seem to stay listed in QA forever.)
>
>
|||"A_Michigan_User" wrote:
> I can use the Client Network Utility (CNU) from SQL 2000 to
> create/delete aliases.
> But when I 1st run Query Analyzer (QA)... it shows a list of some old
> servers we used to have... long ago.
> How do I delete from that list?
> (The old servers have already been removed from the CNU alias list...
> but they seem to stay listed in QA forever.)
For QA, the servers are stored here in the registration database:
HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL
Server\80\Tools\Client\PrefServers
You can remove the pairs you do not need - carefully. I don't know how
to remove servers from the QA drop-down list in the connection dialog
other than by editing the regdb. I see different servers listed in QA
than I have for SQLEM, so removing the server from SQLEM does seem like
it will work in QA.
David Gugick - SQL Server MVP
Quest Software
|||> They have nothing to do with each other.
I thought I *HAD TO* add them with CNU... then they appeared as "available"
in QA and EM.
No?
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:eP%237NMyOGHA.1312@.TK2MSFTNGP09.phx.gbl...[vbcol=seagreen]
> They have nothing to do with each other. Any registrations you did in QA
> or EM you will have to manually delete them from the registrations by
> right clicking and choosing Delete.
> --
> Andrew J. Kelly SQL MVP
>
> ""A_Michigan_User"" <Michigan_RE_M0VE@.ameritech.net> wrote in message
> news:%23gKQ7lwOGHA.3944@.tk2msftngp13.phx.gbl...
|||The CNU just allowed you to alias them. Then maybe you can see them thru
the alias but that is not a requirement to register a server. You just need
the name or IP address of the server and it has to be available on the right
port, 1433 by default.
Andrew J. Kelly SQL MVP
""A_Michigan_User"" <Michigan_RE_M0VE@.ameritech.net> wrote in message
news:eqFg7jlRGHA.2156@.tk2msftngp13.phx.gbl...
> I thought I *HAD TO* add them with CNU... then they appeared as
> "available" in QA and EM.
> No?
>
> "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
> news:eP%237NMyOGHA.1312@.TK2MSFTNGP09.phx.gbl...
>

Thursday, March 22, 2012

Deleting extra tempdb log and data files

We had someone create an extra data file and log file for tempdb. So
we currently have two data files and two log files. Is it possible to
delete the newly created data and log files? If I just delete the
physical files, I assume they'll get created as soon as SQL Server
gets started back up. Any help would be great, since a single data
and log file for tempdb is my goal.

Thanks much.

sean"Sean Lambert" <slambert007@.yahoo.com> wrote in message
news:279f38c0.0309241527.1e7b2546@.posting.google.c om...
> We had someone create an extra data file and log file for tempdb. So
> we currently have two data files and two log files. Is it possible to
> delete the newly created data and log files? If I just delete the
> physical files, I assume they'll get created as soon as SQL Server
> gets started back up. Any help would be great, since a single data
> and log file for tempdb is my goal.

You should be able to simply shut down SQL Server, delete them (back them up
just in case :-) and start it back.

(assuming SQL 2000).

If not, I'd probably try starting SQL Server in single user mode and
removing them there.

But, again, back up everything etc.

> Thanks much.
>
> sean|||slambert007@.yahoo.com (Sean Lambert) wrote in message news:<279f38c0.0309241527.1e7b2546@.posting.google.com>...
> We had someone create an extra data file and log file for tempdb. So
> we currently have two data files and two log files. Is it possible to
> delete the newly created data and log files? If I just delete the
> physical files, I assume they'll get created as soon as SQL Server
> gets started back up. Any help would be great, since a single data
> and log file for tempdb is my goal.
> Thanks much.
>
> sean

Assuming you have SQL2000, then this covers it:

http://support.microsoft.com/?kbid=814576

In summary, use DBCC SHRINKFILE with EMPTYFILE to remove any data on
the files, then ALTER DATABASE ... REMOVE FILE.

Simon|||I'm using SQL7. Sorry...I should have mentioned that initially. Thanks!

sean

sql@.hayes.ch (Simon Hayes) wrote in message news:<60cd0137.0309250040.1a1813d6@.posting.google.com>...
> slambert007@.yahoo.com (Sean Lambert) wrote in message news:<279f38c0.0309241527.1e7b2546@.posting.google.com>...
> > We had someone create an extra data file and log file for tempdb. So
> > we currently have two data files and two log files. Is it possible to
> > delete the newly created data and log files? If I just delete the
> > physical files, I assume they'll get created as soon as SQL Server
> > gets started back up. Any help would be great, since a single data
> > and log file for tempdb is my goal.
> > Thanks much.
> > sean
> Assuming you have SQL2000, then this covers it:
> http://support.microsoft.com/?kbid=814576
> In summary, use DBCC SHRINKFILE with EMPTYFILE to remove any data on
> the files, then ALTER DATABASE ... REMOVE FILE.
> Simon

Deleting duplicate records from a table.....

I loaded one table via SSIS and found that it contained many duplicate records (from the input source). I can create a SQL task to delete them, but I wonder if SSIS offers and task "out of the box" to delete dups?

TAI,

barkingdog

I don't know about anything in SSIS to do so but here's a great way to do it using CTE's and Row_Number()

http://www.sqlservercentral.com/columnists/chawkins/dedupingdatainsqlserver2005.asp

|||

Use a Sort transform from SSIS is a possible alternation - Sort on certain keys and check "remove duplicate records" at Sort transform.

hth

wenyang

Wednesday, March 21, 2012

deleting all rows in table which references itself

Using SQL Server 2000.
The example code below shows a
table which references itself.
i.e. column "parent" references column "pk" :
==
create table table1 (pk int not null primary key, parent int null,
aname varchar(50) null)
alter table table1 add constraint fk_table1_table1
foreign key (parent) references table1 (pk)
go
insert table1 values (1, null, 'one')
insert table1 values (11, 1, 'one-one')
go
delete from table1 -- XX
==
Say I want to delete all rows from the table,
as at the line marked at "XX". Is the
SQL server processing of the delete
statement, such that the delete statement
will always succeed, or can I actually
get a constraint violation in the above example ?
I'm not seeing a constraint violation, but I'm not
sure if this is by luck, or by design.
TIA,
StephenStephen
You can get an error only if you will provide WHERE condition such as
delete from table1 where pk=1
If you can explain what are you trying to do , so it will be more easier to
came up with a solution.
"Stephen Ahn" <noaddress_at_noaddress.com> wrote in message
news:OLFHs3YNFHA.1732@.TK2MSFTNGP14.phx.gbl...
> Using SQL Server 2000.
> The example code below shows a
> table which references itself.
> i.e. column "parent" references column "pk" :
> ==
> create table table1 (pk int not null primary key, parent int null,
> aname varchar(50) null)
> alter table table1 add constraint fk_table1_table1
> foreign key (parent) references table1 (pk)
> go
> insert table1 values (1, null, 'one')
> insert table1 values (11, 1, 'one-one')
> go
> delete from table1 -- XX
> ==
>
> Say I want to delete all rows from the table,
> as at the line marked at "XX". Is the
> SQL server processing of the delete
> statement, such that the delete statement
> will always succeed, or can I actually
> get a constraint violation in the above example ?
> I'm not seeing a constraint violation, but I'm not
> sure if this is by luck, or by design.
>
> TIA,
> Stephen
>|||Uri,
What I was trying to work out was a safe way to delete all records in
tables which reference themselves, as in the example.
ie.
1) is it 100% safe to do : delete from table1,
("safe", as in : no constraint violation will ever be raised
in cases similar to the example, and all records will get
properly deleted). The table could also have many records
in reality.
OR
2) should I write a stored proc etc which deletes records
one by one, deleting child records first, then eventally
deleting the root nodes.
From your reply, it sounds like 1) is true.
Thanks,
Stephen
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:uvY6iHbNFHA.2680@.TK2MSFTNGP09.phx.gbl...
> Stephen
> You can get an error only if you will provide WHERE condition such as
> delete from table1 where pk=1
> If you can explain what are you trying to do , so it will be more easier
> to
> came up with a solution.
>|||Stephen
Again, you are asking to different questions
Do you really want NO WHERE condition in your query?
I think the option 2 is right way to do that.
"Stephen Ahn" <noaddress_at_noaddress.com> wrote in message
news:euTJhZbNFHA.1732@.TK2MSFTNGP14.phx.gbl...
> Uri,
> What I was trying to work out was a safe way to delete all records in
> tables which reference themselves, as in the example.
> ie.
> 1) is it 100% safe to do : delete from table1,
> ("safe", as in : no constraint violation will ever be raised
> in cases similar to the example, and all records will get
> properly deleted). The table could also have many records
> in reality.
> OR
> 2) should I write a stored proc etc which deletes records
> one by one, deleting child records first, then eventally
> deleting the root nodes.
> From your reply, it sounds like 1) is true.
> Thanks,
> Stephen
>
> "Uri Dimant" <urid@.iscar.co.il> wrote in message
> news:uvY6iHbNFHA.2680@.TK2MSFTNGP09.phx.gbl...
>|||"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:%230IbsOcNFHA.3772@.TK2MSFTNGP15.phx.gbl...
> Do you really want NO WHERE condition in your query?
Yes, this is a special case where we actually want to clean out the table
completely.
Thanks,
Stephen|||DELETE FROM Table1
is "safe" in the sense that it will not cause any violations of the
self-referencing foreign key. Constraints are validated against the
final result of a DML operation (except in the special case where you
use user-defined functions in a constraint and the function references
other rows in the same table).
David Portas
SQL Server MVP
--

Monday, March 19, 2012

Deleting a login account

I'm getting the below error when trying to change a few properties for a
login account. If I delete the login from Ent. Manager and then create a new
login with the same name, I get the same error.
I can create a new user as long as i use any other name. How can this
account already exist after I manually delete it?
Is there some code I can run to find this account and delete it? It's almost
like this particular account is hidden somewhere else within SQL.
This is SQL 2000.
ERROR ***********
Microsoft SQL-DMO
Error 21002:[SQL-DMO] User 'myUser' already exists.Did you do a restore operation? Did you refresh?
"scott" wrote:

> I'm getting the below error when trying to change a few properties for a
> login account. If I delete the login from Ent. Manager and then create a n
ew
> login with the same name, I get the same error.
> I can create a new user as long as i use any other name. How can this
> account already exist after I manually delete it?
> Is there some code I can run to find this account and delete it? It's almo
st
> like this particular account is hidden somewhere else within SQL.
> This is SQL 2000.
> ERROR ***********
> Microsoft SQL-DMO
> Error 21002:[SQL-DMO] User 'myUser' already exists.
>
>|||I just re-installed sql on the server, then attached my databases. After
that, this problem surfaced.
"Ata John" <AtaJohn@.discussions.microsoft.com> wrote in message
news:C9C4A787-1E6C-4C46-96AE-A3BE8FCBC454@.microsoft.com...
> Did you do a restore operation? Did you refresh?
> "scott" wrote:
>

Sunday, March 11, 2012

DeleteSubscription leaves job in SQL Server

Has anyone else noticed that if you create a timed subscription using

the web service and then delete it using the DeleteSubscription method,

there is a job (id'ed by a guid) left in SQL Server Jobs?

Consequently we now have hundres of "orphaned" jobs in our database :-(

A bit more investigation appears to reveal this:

I use data driven subscriptions and create them using CreateDataDrivenSubscription. Therefore I retrieve them using GetDataDrivenSubscriptionProperties. The matchData returned does not contain a scheduleId. Is that correct? Well calling ListSchedules returns an empty row, indicating that the schedules created are not shared, so cannot be deleted using DeleteSchedule anyway. However, and this is where the bug appears to be, the schedules are in the ReportSchedule table and the jobs are in SQL Server. Calling DeleteSubscription does not delete the SQL Server Job, nor does it delete the row from ReportSchedule. Is this a bug? Is there a fix or do I have to delete the row myself and delete the job from SQL Server using DMO or some such hack.

|||

The SQL Agent jobs should be deleted when the associated subscription is deleted. There appears to be a problem with your system.

Can you take a peek at Event Viewer and SQLAgent log files and see if there is any incriminating evidence?

Saturday, February 25, 2012

Delete trigger in SQL Server 7

Have gone through BOL and Google, but can't find the answer... please help
with a simple Q. I'm trying to create a simple cascade delete trigger in SQL
Server 7 where deleting "parent" records in table X delete corresponding
child records in table Y.

Table X
=========
X_ID
SOME_VAL

Table Y
=========
Y_ID
X_ID
SOME_VAL

When there is no relationship between X.X_ID and Y.X_ID, the following
trigger works fine:

CREATE TRIGGER "temp" ON x
FOR DELETE
AS

delete
from y
where x_id in (select x_id from deleted)

However, when a relationship is created to enforce referential integrity,
the trigger fails, with a "DELETE statement conflicted with COLUMN REFERENCE
constraint" error. I've seen examples where the trigger says (for example)
"AFTER INSERT", where presumably the code is specifically run after the
event that triggers it -- is there a way of forcing the trigger to run
before the delete from table X is executed? I've tried using "BEFORE
DELETE", but no dice :-\

Thanks!

--
Aidan Whitehall <aidanwhitehall@.fairbanks.co.uk>
Macromedia ColdFusion Developer
Fairbanks Environmental Ltd +44 (0)1695 51775Itzik Ben-Gan and Thomas Moreau have some examples of cascading RI triggers
in their white paper:
<http://www.msdn.microsoft.com/libra...ry/en-us/dnsql2
k/html/sql_refintegrity.asp?frame=true>.

The main consideration is that you cannot have declarative referential
integrity in place when you perform cascading actions in triggers in SQL 7,
..

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Aidan Whitehall" <aidanwhitehall@.fairbanks.co.uk> wrote in message
news:btph6b$kri$1@.sparta.btinternet.com...
> Have gone through BOL and Google, but can't find the answer... please help
> with a simple Q. I'm trying to create a simple cascade delete trigger in
SQL
> Server 7 where deleting "parent" records in table X delete corresponding
> child records in table Y.
> Table X
> =========
> X_ID
> SOME_VAL
> Table Y
> =========
> Y_ID
> X_ID
> SOME_VAL
>
> When there is no relationship between X.X_ID and Y.X_ID, the following
> trigger works fine:
> CREATE TRIGGER "temp" ON x
> FOR DELETE
> AS
> delete
> from y
> where x_id in (select x_id from deleted)
> However, when a relationship is created to enforce referential integrity,
> the trigger fails, with a "DELETE statement conflicted with COLUMN
REFERENCE
> constraint" error. I've seen examples where the trigger says (for example)
> "AFTER INSERT", where presumably the code is specifically run after the
> event that triggers it -- is there a way of forcing the trigger to run
> before the delete from table X is executed? I've tried using "BEFORE
> DELETE", but no dice :-\
>
> Thanks!
> --
> Aidan Whitehall <aidanwhitehall@.fairbanks.co.uk>
> Macromedia ColdFusion Developer
> Fairbanks Environmental Ltd +44 (0)1695 51775|||> Itzik Ben-Gan and Thomas Moreau have some examples of cascading RI
triggers
> in their white paper:
<http://www.msdn.microsoft.com/libra...ry/en-us/dnsql2
> k/html/sql_refintegrity.asp?frame=true>.

K, thanks -- I'll check that out.

> The main consideration is that you cannot have declarative referential
> integrity in place when you perform cascading actions in triggers in SQL
7,

Damn, damn, damn.

Well, thanks for the clarification, anyway.

Regards

--
Aidan Whitehall <aidanwhitehall@.fairbanks.co.uk>
Macromedia ColdFusion Developer
Fairbanks Environmental Ltd +44 (0)1695 51775|||Aidan Whitehall wrote:

>>The main consideration is that you cannot have declarative referential
>>integrity in place when you perform cascading actions in triggers in SQL
> 7,
> Damn, damn, damn.
> Well, thanks for the clarification, anyway.

If I may request it ... would someone please confirm the above statement
about SQL Server. This statement is untrue is other commercial RDBMS
products, such as Oracle and DB2, and I would be surprised if SQL Server
didn't allow this very basic functionality. Is is still true in the
current version?

Thanks.

--
Daniel Morgan
http://www.outreach.washington.edu/...oad/oad_crs.asp
http://www.outreach.washington.edu/...aoa/aoa_crs.asp
damorgan@.x.washington.edu
(replace 'x' with a 'u' to reply)|||> If I may request it ... would someone please confirm the above statement
> about SQL Server. This statement is untrue is other commercial RDBMS
> products, such as Oracle and DB2, and I would be surprised if SQL Server
> didn't allow this very basic functionality. Is is still true in the
> current version?

One can implement cascading actions via DRI or INSTEAD OF triggers in
current version of SQL Server (SQL Server 2000).

Unfortunately, Aidan is using an older version (SQL 7) in which only the
AFTER trigger model is available. Consequently, it is necessary to enforce
referential integrity in triggers instead of DRI in cases when cascading
actions are performed in triggers. Another alternative is to perform
cascading functions via stored procedures.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Daniel Morgan" <damorgan@.x.washington.edu> wrote in message
news:1073846407.832632@.yasure...
> Aidan Whitehall wrote:
> >>The main consideration is that you cannot have declarative referential
> >>integrity in place when you perform cascading actions in triggers in SQL
> > 7,
> > Damn, damn, damn.
> > Well, thanks for the clarification, anyway.
> If I may request it ... would someone please confirm the above statement
> about SQL Server. This statement is untrue is other commercial RDBMS
> products, such as Oracle and DB2, and I would be surprised if SQL Server
> didn't allow this very basic functionality. Is is still true in the
> current version?
> Thanks.
> --
> Daniel Morgan
> http://www.outreach.washington.edu/...oad/oad_crs.asp
> http://www.outreach.washington.edu/...aoa/aoa_crs.asp
> damorgan@.x.washington.edu
> (replace 'x' with a 'u' to reply)|||Dan Guzman wrote:

>>If I may request it ... would someone please confirm the above statement
>>about SQL Server. This statement is untrue is other commercial RDBMS
>>products, such as Oracle and DB2, and I would be surprised if SQL Server
>>didn't allow this very basic functionality. Is is still true in the
>>current version?
>
> One can implement cascading actions via DRI or INSTEAD OF triggers in
> current version of SQL Server (SQL Server 2000).
> Unfortunately, Aidan is using an older version (SQL 7) in which only the
> AFTER trigger model is available. Consequently, it is necessary to enforce
> referential integrity in triggers instead of DRI in cases when cascading
> actions are performed in triggers. Another alternative is to perform
> cascading functions via stored procedures.

Thanks. I was a bit surprised that such basic functionality might not
exist. In Oracle one can always perform cascading deletes in any code
but the referential constraint, itself, will perform the function. For
example:

ALTER TABLE child
ADD CONSTRAINT fk_child_parent
FOREIGN KEY (test)
REFERENCES parent (test)
ON DELETE CASCADE;

Thanks again for the clarification.

--
Daniel Morgan
http://www.outreach.washington.edu/...oad/oad_crs.asp
http://www.outreach.washington.edu/...aoa/aoa_crs.asp
damorgan@.x.washington.edu
(replace 'x' with a 'u' to reply)|||> Thanks. I was a bit surprised that such basic functionality might not
> exist. In Oracle one can always perform cascading deletes in any code
> but the referential constraint, itself, will perform the function. For
> example:
> ALTER TABLE child
> ADD CONSTRAINT fk_child_parent
> FOREIGN KEY (test)
> REFERENCES parent (test)
> ON DELETE CASCADE;

The same syntax works in SQL 2000. Thank goodness for ANSI standards ;-)

BEGIN TRAN

CREATE TABLE parent(test int NOT NULL PRIMARY KEY)
CREATE TABLE child(test int NOT NULL PRIMARY KEY)

ALTER TABLE child
ADD CONSTRAINT fk_child_parent
FOREIGN KEY (test)
REFERENCES parent (test)
ON DELETE CASCADE;

insert into parent values(1)
insert into child values(1)

delete from parent
select * from parent --no rows
select * from child --no rows

ROLLBACK

--
Hope this helps.

Dan Guzman
SQL Server MVP|||Dan Guzman wrote:

>>Thanks. I was a bit surprised that such basic functionality might not
>>exist. In Oracle one can always perform cascading deletes in any code
>>but the referential constraint, itself, will perform the function. For
>>example:
>>
>>ALTER TABLE child
>>ADD CONSTRAINT fk_child_parent
>>FOREIGN KEY (test)
>>REFERENCES parent (test)
>>ON DELETE CASCADE;
>
> The same syntax works in SQL 2000. Thank goodness for ANSI standards ;-)
> BEGIN TRAN
> CREATE TABLE parent(test int NOT NULL PRIMARY KEY)
> CREATE TABLE child(test int NOT NULL PRIMARY KEY)
> ALTER TABLE child
> ADD CONSTRAINT fk_child_parent
> FOREIGN KEY (test)
> REFERENCES parent (test)
> ON DELETE CASCADE;
> insert into parent values(1)
> insert into child values(1)
> delete from parent
> select * from parent --no rows
> select * from child --no rows
> ROLLBACK

Excellent. Thanks.

Like I said ... I would have been quite surprised if it didn't exist.

--
Daniel Morgan
http://www.outreach.washington.edu/...oad/oad_crs.asp
http://www.outreach.washington.edu/...aoa/aoa_crs.asp
damorgan@.x.washington.edu
(replace 'x' with a 'u' to reply)

Delete Trigger

Dear All
I am trying to create a DELETE Trigger on a table which will delete a
previous record for a given value entered.
[1] I create a table with two columns called ItemName, TimeStamp (when the
record was last inserted/updated).
[2] I Insert a value of 'Table' into ItemName.
[3] I Insert a value of 'Chair' into ItemName
[4] If I add another entry of 'Table' into ItemName and the Trigger will
find the previous entry for 'Table' and delete it.
What I don't understand is how to get the value on the newly added column
and then serach for the 'duplicate' record to delete?
I apologise if I am not clear as I am a newbie at SQL Server.
Thanks for the continued support of the group and especially Louis Davidson
who helped me with a similar post.
Alastair MacFarlaneyou dont need a triger for delete, you need a trigger for insert that
deletes the record. In the trigger, you have a table 'inserted'. Table
'inserted' has new data, or data you're inserting. So you can write
something like:
CREATE TRIGGER trigerName
ON Table
FOR INSERT
AS
BEGIN
delete
from
table t
inner join inserted i on t.itemname = i.itemname
where
t.timestamp < i.timestamp
END
This will delete ALL records from table with the same itemName and lower
timestamp. You also might want to think about updates.
What should happen if someone updates the ItemName column?
MC
"Alastair MacFarlane" <AlastairMacFarlane@.discussions.microsoft.com> wrote
in message news:8306D794-88DB-4C39-942D-BF62E7822170@.microsoft.com...
> Dear All
> I am trying to create a DELETE Trigger on a table which will delete a
> previous record for a given value entered.
> [1] I create a table with two columns called ItemName, TimeStamp (when the
> record was last inserted/updated).
> [2] I Insert a value of 'Table' into ItemName.
> [3] I Insert a value of 'Chair' into ItemName
> [4] If I add another entry of 'Table' into ItemName and the Trigger will
> find the previous entry for 'Table' and delete it.
> What I don't understand is how to get the value on the newly added column
> and then serach for the 'duplicate' record to delete?
> I apologise if I am not clear as I am a newbie at SQL Server.
> Thanks for the continued support of the group and especially Louis
> Davidson
> who helped me with a similar post.
> Alastair MacFarlane|||Hi
I think you need a trigger for INSERT
Try this one (untested)
create table r (col1 int not null primary key,
col2 char(1) not null)
create trigger my_tr on r for insert
as
if exists (select count(*),col2 from
r group by col2 having count(*)>1)
delete r
from r join inserted i on r.col2=i.col2 and r.col1<i.col1
--test
insert into r values (1,'a')
insert into r values (2,'b')
insert into r values (3,'c')
insert into r values (4,'c')
select * from r
"Alastair MacFarlane" <AlastairMacFarlane@.discussions.microsoft.com> wrote
in message news:8306D794-88DB-4C39-942D-BF62E7822170@.microsoft.com...
> Dear All
> I am trying to create a DELETE Trigger on a table which will delete a
> previous record for a given value entered.
> [1] I create a table with two columns called ItemName, TimeStamp (when the
> record was last inserted/updated).
> [2] I Insert a value of 'Table' into ItemName.
> [3] I Insert a value of 'Chair' into ItemName
> [4] If I add another entry of 'Table' into ItemName and the Trigger will
> find the previous entry for 'Table' and delete it.
> What I don't understand is how to get the value on the newly added column
> and then serach for the 'duplicate' record to delete?
> I apologise if I am not clear as I am a newbie at SQL Server.
> Thanks for the continued support of the group and especially Louis
> Davidson
> who helped me with a similar post.
> Alastair MacFarlane|||An instead of trigger would do well for this
CREATE TABLE furniture (ItemName varchar(512), [TimeStamp] timestamp)
GO
INSERT INTO furniture (ItemName) VALUES ('TABLE')
INSERT INTO furniture (ItemName) VALUES ('CHAIR')
SELECT ItemName, [TimeStamp] FROM furniture
/*
ItemName TimeStamp
---
TABLE 0x0000000000002025
CHAIR 0x0000000000002026
*/
DROP TRIGGER trigger1
GO
CREATE TRIGGER trigger1 ON furniture
INSTEAD OF INSERT
AS
SET NOCOUNT ON
UPDATE furniture SET ItemName = i.ItemName
FROM inserted i INNER JOIN furniture f ON f.ItemName = i.ItemName
INSERT INTO furniture (ItemName) SELECT ItemName FROM inserted i
WHERE NOT EXISTS (SELECT 1 FROM furniture f WHERE i.ItemName = f.ItemName)
SET NOCOUNT OFF
INSERT INTO furniture (ItemName) VALUES ('Ottoman')
INSERT INTO furniture (ItemName) VALUES ('TABLE')
SELECT ItemName, [TimeStamp] FROM furniture
/*
ItemName TimeStamp
-- --
TABLE 0x0000000000002029
CHAIR 0x0000000000002026
Ottoman 0x0000000000002028
*/
--
"Alastair MacFarlane" wrote:

> Dear All
> I am trying to create a DELETE Trigger on a table which will delete a
> previous record for a given value entered.
> [1] I create a table with two columns called ItemName, TimeStamp (when the
> record was last inserted/updated).
> [2] I Insert a value of 'Table' into ItemName.
> [3] I Insert a value of 'Chair' into ItemName
> [4] If I add another entry of 'Table' into ItemName and the Trigger will
> find the previous entry for 'Table' and delete it.
> What I don't understand is how to get the value on the newly added column
> and then serach for the 'duplicate' record to delete?
> I apologise if I am not clear as I am a newbie at SQL Server.
> Thanks for the continued support of the group and especially Louis Davidso
n
> who helped me with a similar post.
> Alastair MacFarlane|||Xref: TK2MSFTNGP08.phx.gbl microsoft.public.sqlserver.programming:583593
Alastair,
I'm not sure you really want to create a duplicate and delete it. Here
is another way (Uri, thanks for setting up the data):
create table r (col1 int not null primary key,
col2 char(1) not null)
go
create view r_v
as
select * from r
go
create trigger my_tr on r_v
instead of insert
as
begin
update r set r.col2 = inserted.col2
from r,inserted
where r.col1=inserted.col1
insert into r
select inserted.col1, inserted.col2
from inserted left outer join r
on r.col1=inserted.col1
where r.col1 is null
end
go
--test
insert into r values (1,'a')
insert into r values (2,'b')
insert into r values (3,'c')
-- this will update the row with col1=1
insert into r_v values (1,'c')
go
select * from r
col1 col2
-- --
1 c
2 b
3 c
go
insert into r_v
-- this row is inserted
select 4, 'D'
union all
-- this row is updated
select 2, 'e'
go
select * from r
col1 col2
-- --
1 c
2 e
3 c
4 D
(4 row(s) affected)
go
drop table r
drop view r_v|||Sorry, I thought from your DDL that you were using a column with a datatype
of timestamp. Here is the trigger re-written for a column of datatype
datetime.
DROP TABLE furniture
GO
CREATE TABLE furniture (ItemName char(20), [TimeStamp] datetime)
GO
INSERT INTO furniture VALUES ('TABLE',GETDATE())
INSERT INTO furniture VALUES ('CHAIR',GETDATE())
SELECT ItemName, [TimeStamp] FROM furniture
/*
ItemName TimeStamp
-- --
TABLE 2006-02-09 08:38:35.173
CHAIR 2006-02-09 08:38:35.190
*/
DROP TRIGGER trigger1
GO
CREATE TRIGGER trigger1 ON furniture
INSTEAD OF INSERT
AS
SET NOCOUNT ON
UPDATE furniture SET [TimeStamp] = GETDATE()
FROM inserted i INNER JOIN furniture f ON f.ItemName = i.ItemName
INSERT INTO furniture SELECT ItemName, GETDATE() FROM inserted i
WHERE NOT EXISTS (SELECT 1 FROM furniture f WHERE i.ItemName = f.ItemName)
SET NOCOUNT OFF
INSERT INTO furniture (ItemName) VALUES ('Ottoman')
INSERT INTO furniture (ItemName) VALUES ('TABLE')
SELECT ItemName, [TimeStamp] FROM furniture
/*
ItemName TimeStamp
-- --
TABLE 2006-02-09 08:39:45.410
CHAIR 2006-02-09 08:38:35.190
Ottoman 2006-02-09 08:39:43.440
*/
"Mark Williams" wrote:
> An instead of trigger would do well for this
> CREATE TABLE furniture (ItemName varchar(512), [TimeStamp] timestamp)
> GO
> INSERT INTO furniture (ItemName) VALUES ('TABLE')
> INSERT INTO furniture (ItemName) VALUES ('CHAIR')
> SELECT ItemName, [TimeStamp] FROM furniture
> /*
> ItemName TimeStamp
> ---
> TABLE 0x0000000000002025
> CHAIR 0x0000000000002026
> */
> DROP TRIGGER trigger1
> GO
> CREATE TRIGGER trigger1 ON furniture
> INSTEAD OF INSERT
> AS
> SET NOCOUNT ON
> UPDATE furniture SET ItemName = i.ItemName
> FROM inserted i INNER JOIN furniture f ON f.ItemName = i.ItemName
> INSERT INTO furniture (ItemName) SELECT ItemName FROM inserted i
> WHERE NOT EXISTS (SELECT 1 FROM furniture f WHERE i.ItemName = f.ItemNam
e)
> SET NOCOUNT OFF
> INSERT INTO furniture (ItemName) VALUES ('Ottoman')
> INSERT INTO furniture (ItemName) VALUES ('TABLE')
> SELECT ItemName, [TimeStamp] FROM furniture
> /*
> ItemName TimeStamp
> -- --
> TABLE 0x0000000000002029
> CHAIR 0x0000000000002026
> Ottoman 0x0000000000002028
> */
> --
> "Alastair MacFarlane" wrote:
>|||Mark and others,
Sorry for the delay and thanks for the feedback. I have tested out the
examples provided and they work the way I would expect.
Your help is appreciated.
Alastair MacFarlane
"Mark Williams" wrote:
> Sorry, I thought from your DDL that you were using a column with a datatyp
e
> of timestamp. Here is the trigger re-written for a column of datatype
> datetime.
> DROP TABLE furniture
> GO
> CREATE TABLE furniture (ItemName char(20), [TimeStamp] datetime)
> GO
> INSERT INTO furniture VALUES ('TABLE',GETDATE())
> INSERT INTO furniture VALUES ('CHAIR',GETDATE())
> SELECT ItemName, [TimeStamp] FROM furniture
> /*
> ItemName TimeStamp
> -- --
> TABLE 2006-02-09 08:38:35.173
> CHAIR 2006-02-09 08:38:35.190
> */
> DROP TRIGGER trigger1
> GO
> CREATE TRIGGER trigger1 ON furniture
> INSTEAD OF INSERT
> AS
> SET NOCOUNT ON
> UPDATE furniture SET [TimeStamp] = GETDATE()
> FROM inserted i INNER JOIN furniture f ON f.ItemName = i.ItemName
> INSERT INTO furniture SELECT ItemName, GETDATE() FROM inserted i
> WHERE NOT EXISTS (SELECT 1 FROM furniture f WHERE i.ItemName = f.ItemNam
e)
> SET NOCOUNT OFF
> INSERT INTO furniture (ItemName) VALUES ('Ottoman')
> INSERT INTO furniture (ItemName) VALUES ('TABLE')
> SELECT ItemName, [TimeStamp] FROM furniture
> /*
> ItemName TimeStamp
> -- --
> TABLE 2006-02-09 08:39:45.410
> CHAIR 2006-02-09 08:38:35.190
> Ottoman 2006-02-09 08:39:43.440
> */
> --
> "Mark Williams" wrote:
>

delete trigger

I am trying to create a trigger where if the check box iin infopath is
checked then it deletes the whole record from the database. I am not sure
where to even start on this trigger. Please Help.Hi Ben
You may get a better response on how infopath works in
microsoft.public.infopath
John
"Ben Watts" wrote:
> I am trying to create a trigger where if the check box iin infopath is
> checked then it deletes the whole record from the database. I am not sure
> where to even start on this trigger. Please Help.
>
>

delete trigger

I am trying to create a trigger where if the check box iin infopath is
checked then it deletes the whole record from the database. I am not sure
where to even start on this trigger. Please Help.Hi Ben
You may get a better response on how infopath works in
microsoft.public.infopath
John
"Ben Watts" wrote:

> I am trying to create a trigger where if the check box iin infopath is
> checked then it deletes the whole record from the database. I am not sure
> where to even start on this trigger. Please Help.
>
>

Delete subscription problem

Hi,
I create both non-data-driven subscription and data-driven subscription in
my application for one report. Is there any way to distinguish those two
subscriptions? So I can delete them, since Reporting Services uses different
functions to delete the non-data-driven subscription and data-driven
subscription.
Thank you very much for your help!
MichelleListSubscriptions returns both types and has a bool which tells you if the
subscription is a data driven subscription.
--
-Daniel
This posting is provided "AS IS" with no warranties, and confers no rights.
"Michelle" <Michelle@.discussions.microsoft.com> wrote in message
news:E44A9504-2058-4F74-9D47-7473DB69FE94@.microsoft.com...
> Hi,
> I create both non-data-driven subscription and data-driven subscription in
> my application for one report. Is there any way to distinguish those two
> subscriptions? So I can delete them, since Reporting Services uses
> different
> functions to delete the non-data-driven subscription and data-driven
> subscription.
> Thank you very much for your help!
> Michelle|||Thank you!!!
"Daniel Reib (MSFT)" wrote:
> ListSubscriptions returns both types and has a bool which tells you if the
> subscription is a data driven subscription.
> --
> -Daniel
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "Michelle" <Michelle@.discussions.microsoft.com> wrote in message
> news:E44A9504-2058-4F74-9D47-7473DB69FE94@.microsoft.com...
> > Hi,
> >
> > I create both non-data-driven subscription and data-driven subscription in
> > my application for one report. Is there any way to distinguish those two
> > subscriptions? So I can delete them, since Reporting Services uses
> > different
> > functions to delete the non-data-driven subscription and data-driven
> > subscription.
> >
> > Thank you very much for your help!
> >
> > Michelle
>
>

Friday, February 24, 2012

Delete SQL server registration

Hello!
I would like to set up replication (cluster) on my SQL server 2000.
Unfortunately the server name is local so I cant create the replication. I
have to delete the server registration and create a new one with the servers
actual name. This is a production server. If I delete the registration
server and create a new one, will all my databases bee gone? Do I have to
create them from scratch or restore them from backup?
Hi,
You can very well delete the registration and re-register again.
This deletion just removes the entries from Enterprise manager and will not
create any impact to SQL server database or objects.
Thanks
Hari
SQL Server MVP
"Terje Sundbe" <tsundboe@.msn.com> wrote in message
news:uy1cNjSuFHA.2592@.TK2MSFTNGP09.phx.gbl...
> Hello!
> I would like to set up replication (cluster) on my SQL server 2000.
> Unfortunately the server name is local so I cant create the replication. I
> have to delete the server registration and create a new one with the
> servers actual name. This is a production server. If I delete the
> registration server and create a new one, will all my databases bee gone?
> Do I have to create them from scratch or restore them from backup?
>
|||The registration is just a connection into the MMC. You can safely delete
the registration. Make sure you've got the sa password before doing this
just in case!
"Terje Sundb?e" wrote:

> Hello!
> I would like to set up replication (cluster) on my SQL server 2000.
> Unfortunately the server name is local so I cant create the replication. I
> have to delete the server registration and create a new one with the servers
> actual name. This is a production server. If I delete the registration
> server and create a new one, will all my databases bee gone? Do I have to
> create them from scratch or restore them from backup?
>
>
|||Thank you for your swift reply
Can I set up a two node cluster with SQL server 200 enterprise edition and
windows server 2003 standard edition?
"Terje Sundbe" <tsundboe@.msn.com> wrote in message
news:uy1cNjSuFHA.2592@.TK2MSFTNGP09.phx.gbl...
> Hello!
> I would like to set up replication (cluster) on my SQL server 2000.
> Unfortunately the server name is local so I cant create the replication. I
> have to delete the server registration and create a new one with the
> servers actual name. This is a production server. If I delete the
> registration server and create a new one, will all my databases bee gone?
> Do I have to create them from scratch or restore them from backup?
>
|||Hi,
You need windows 2003 Enterprise Edition to setup the 2 node cluster.
Regards
Srini
"Terje Sundb?e" wrote:

> Thank you for your swift reply
> Can I set up a two node cluster with SQL server 200 enterprise edition and
> windows server 2003 standard edition?
> "Terje Sundb?e" <tsundboe@.msn.com> wrote in message
> news:uy1cNjSuFHA.2592@.TK2MSFTNGP09.phx.gbl...
>
>

Delete SQL server registration

Hello!
I would like to set up replication (cluster) on my SQL server 2000.
Unfortunately the server name is local so I cant create the replication. I
have to delete the server registration and create a new one with the servers
actual name. This is a production server. If I delete the registration
server and create a new one, will all my databases bee gone? Do I have to
create them from scratch or restore them from backup?Hi,
You can very well delete the registration and re-register again.
This deletion just removes the entries from Enterprise manager and will not
create any impact to SQL server database or objects.
Thanks
Hari
SQL Server MVP
"Terje Sundbe" <tsundboe@.msn.com> wrote in message
news:uy1cNjSuFHA.2592@.TK2MSFTNGP09.phx.gbl...
> Hello!
> I would like to set up replication (cluster) on my SQL server 2000.
> Unfortunately the server name is local so I cant create the replication. I
> have to delete the server registration and create a new one with the
> servers actual name. This is a production server. If I delete the
> registration server and create a new one, will all my databases bee gone?
> Do I have to create them from scratch or restore them from backup?
>|||The registration is just a connection into the MMC. You can safely delete
the registration. Make sure you've got the sa password before doing this
just in case!
"Terje Sundb?e" wrote:

> Hello!
> I would like to set up replication (cluster) on my SQL server 2000.
> Unfortunately the server name is local so I cant create the replication. I
> have to delete the server registration and create a new one with the serve
rs
> actual name. This is a production server. If I delete the registration
> server and create a new one, will all my databases bee gone? Do I have to
> create them from scratch or restore them from backup?
>
>|||Thank you for your swift reply
Can I set up a two node cluster with SQL server 200 enterprise edition and
windows server 2003 standard edition?
"Terje Sundbe" <tsundboe@.msn.com> wrote in message
news:uy1cNjSuFHA.2592@.TK2MSFTNGP09.phx.gbl...
> Hello!
> I would like to set up replication (cluster) on my SQL server 2000.
> Unfortunately the server name is local so I cant create the replication. I
> have to delete the server registration and create a new one with the
> servers actual name. This is a production server. If I delete the
> registration server and create a new one, will all my databases bee gone?
> Do I have to create them from scratch or restore them from backup?
>|||Hi,
You need windows 2003 Enterprise Edition to setup the 2 node cluster.
Regards
Srini
"Terje Sundb?e" wrote:

> Thank you for your swift reply
> Can I set up a two node cluster with SQL server 200 enterprise edition and
> windows server 2003 standard edition?
> "Terje Sundb?e" <tsundboe@.msn.com> wrote in message
> news:uy1cNjSuFHA.2592@.TK2MSFTNGP09.phx.gbl...
>
>

Delete SQL server registration

Hello!
I would like to set up replication (cluster) on my SQL server 2000.
Unfortunately the server name is local so I cant create the replication. I
have to delete the server registration and create a new one with the servers
actual name. This is a production server. If I delete the registration
server and create a new one, will all my databases bee gone? Do I have to
create them from scratch or restore them from backup?Hi,
You can very well delete the registration and re-register again.
This deletion just removes the entries from Enterprise manager and will not
create any impact to SQL server database or objects.
Thanks
Hari
SQL Server MVP
"Terje Sundbøe" <tsundboe@.msn.com> wrote in message
news:uy1cNjSuFHA.2592@.TK2MSFTNGP09.phx.gbl...
> Hello!
> I would like to set up replication (cluster) on my SQL server 2000.
> Unfortunately the server name is local so I cant create the replication. I
> have to delete the server registration and create a new one with the
> servers actual name. This is a production server. If I delete the
> registration server and create a new one, will all my databases bee gone?
> Do I have to create them from scratch or restore them from backup?
>|||The registration is just a connection into the MMC. You can safely delete
the registration. Make sure you've got the sa password before doing this
just in case!
"Terje Sundbøe" wrote:
> Hello!
> I would like to set up replication (cluster) on my SQL server 2000.
> Unfortunately the server name is local so I cant create the replication. I
> have to delete the server registration and create a new one with the servers
> actual name. This is a production server. If I delete the registration
> server and create a new one, will all my databases bee gone? Do I have to
> create them from scratch or restore them from backup?
>
>|||Thank you for your swift reply
Can I set up a two node cluster with SQL server 200 enterprise edition and
windows server 2003 standard edition?
"Terje Sundbøe" <tsundboe@.msn.com> wrote in message
news:uy1cNjSuFHA.2592@.TK2MSFTNGP09.phx.gbl...
> Hello!
> I would like to set up replication (cluster) on my SQL server 2000.
> Unfortunately the server name is local so I cant create the replication. I
> have to delete the server registration and create a new one with the
> servers actual name. This is a production server. If I delete the
> registration server and create a new one, will all my databases bee gone?
> Do I have to create them from scratch or restore them from backup?
>|||Hi,
You need windows 2003 Enterprise Edition to setup the 2 node cluster.
Regards
Srini
"Terje Sundbøe" wrote:
> Thank you for your swift reply
> Can I set up a two node cluster with SQL server 200 enterprise edition and
> windows server 2003 standard edition?
> "Terje Sundbøe" <tsundboe@.msn.com> wrote in message
> news:uy1cNjSuFHA.2592@.TK2MSFTNGP09.phx.gbl...
> > Hello!
> >
> > I would like to set up replication (cluster) on my SQL server 2000.
> > Unfortunately the server name is local so I cant create the replication. I
> > have to delete the server registration and create a new one with the
> > servers actual name. This is a production server. If I delete the
> > registration server and create a new one, will all my databases bee gone?
> > Do I have to create them from scratch or restore them from backup?
> >
>
>

Sunday, February 19, 2012

Delete records in SQL table, which are present in Excel

Hi everyone,

I have a task to create a dts package, which will delete records in a SQL table, which are present on a sheet tab in Excel. I know how to transfer records from Excel to SQL table and vice versa, but not sure how I can delete the records in SQL table, which are present in Excel. Note that there are just 2 columns - one is a key and the other name.

Thank you all in advance,
SauravI would NEVER recommend using Excel as source data for a relational database. You are begging for data corruption.

At the very least, load the Excel data into a staging table within your database where it can be cleansed and verified before you start deleting production data based upon its contents.

Bad idea. What is the source of the Excel data?

Friday, February 17, 2012

delete problem

hi all,
can any one tell me why only 906 rows from the temp table are deleted by this sp:??

create PROCEDURE usp_DelAllPersonalContacts11

AS
begin
declare @.contactid int ,@.tempid int ,@.b int
create table #temp (tempid int identity(1,1),contactid int)

set @.b=2000
while @.b>0
begin
insert into #temp (contactid)
values (@.b)
set @.b=@.b-1

end
select * from #temp
declare user_cursor cursor for (select tempid,contactid from #temp )
open user_cursor

fetch next from user_cursor
into @.tempid,@.contactid

while @.@.fetch_status=0
begin
delete from #temp where contactid=@.contactid
print @.contactid
fetch next from user_Cursor
into @.tempid,@.contactid
end
close user_cursor
deallocate user_cursor

select * from #temp

drop table #temp
endWhen I change it into:

delete from #temp where contactid <= @.contactid
if @.@.rowcount <> 1
begin
select 'RC: ', @.@.rowcount
print @.contactid
end

All rows are deleted, @.@.rowcount <> 1 fires once on @.contactid 2000.

But: my guess is that since the cursor has no order by clause it somewhat randomly puts a hold on a next row (whatever that means):

declare user_cursor cursor for
select tempid,contactid
from #temp
order by tempid

works for me with the contactid = @.contactid

delete or drop table then create table

which one is smarter, where there is no indexing on the table which is really simple table delete everything or recreate table. I got an argument with one of my coworker. He says it doesnt matter i say do delete. Any opinions.DELETE is a logged transaction, and so incurs overhead that DROP and RECREATE do not.
For another option, try TRUNCATE table, which is also unlogged.|||well said i did research truncate table and you are of course correct on this. I'll change the code to that :D|||delete *

You crack me up|||Why don't you show us what you're doing, what volume, ect

Where for example are you getting the data from...and if you got into an argument, what did your coworker say?|||Personally I would not allow the drop/create table here, as it carries too many permission implications. Take the matter of the logs up with the DBA involved, and see if the transaction logs will hold up. He may need to add more diskspace, more backups, or both.|||delete *
You crack me upThat's MS Access syntax...|||Heres the code i made

if 0< (select count(*) from dbo.sysobjects where id = object_id(N'[dbo].[_Bootfiles_Summary_Work_Table]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
TRUNCATE TABLE _Bootfiles_Summary_Work_Table
end
else
begin
Create Table _Bootfiles_Summary_Work_Table
(Agency smallint,
Plate_State varchar(20),
Plate varchar(8),
Cite_Count int,
CiteBalance Money)
end

its really simple actually no index no nothing, and in case it gets deleted some code that i dont know this is will recreate the table.

and o yea no star on the delete my mistake.

Tuesday, February 14, 2012

delete log file

Our server is getting pretty full, the data has already been backed up, but it did not create additional room on the server. Can I delete the log file as long as I have backed up the items I need? We are running Microsoft SQL 2000.
Thanks for the help!Then compress and shrink the log files too

That if you have not done it before should clear up some space...

You do backup to a different drive/ server right?|||Thanks for the response. Yes, we do back up to another drive. Do you know what happens if you erase the log files?|||...Do you know what happens if you erase the log files?The database becomes inaccessible. If you deleted the log file AFTER you detached the database, then you'll have hard time recovering it unless you plan to restore it from the backup. If you deleted it AFTER you stopped SQL service, then upon the next service startup the database will be marked Suspect. This situation can be easily fixed using 1 of the 3 known methods.|||The database becomes inaccessible. If you deleted the log file AFTER you detached the database, then you'll have hard time recovering it unless you plan to restore it from the backup. If you deleted it AFTER you stopped SQL service, then upon the next service startup the database will be marked Suspect. This situation can be easily fixed using 1 of the 3 known methods.

I SUSPECT that you are going to tell him.