Showing posts with label current. Show all posts
Showing posts with label current. Show all posts

Friday, March 30, 2012

How do I make sure only one record is the current issue?

I have a table of magazine issues. The table are defined as below:

issueID int Unchecked
name varchar(50) Unchecked
title varchar(100) Checked
description varchar(500) Checked
crntIssue bit Checked
archived bit Checked
navOrder int Checked
dateCreate datetime Checked

And here is what I want. Is there a way when inserting/updating or on the table itself to make sure that there is only one record that is marked as the current issue? The way I have it here in my table, any records can have the current issue (crntIssue) field checked. I only want one crntIssue field checked regardless of how many records or issues are in the table. If there is no way to automatically have SQL Server to manage that then that means I must check all the records before hand before the update/insert query, correct?

You can actually make the change to the remaining records if you used a Trigger.

|||

Thanks for the response. Will you explain in more details? What do you mean by using Trigger? I'm quite new to SQL Server. I don't use it extensively.

|||

A trigger is an object contained within an Sql Server database that is used to execute a batch of SLQ code whenver a specific event occurs such as an UPDATE or INSERT. They can be defined to execute in place of or after data modifications. Therefore you could use an AFTER trigger when inserting a new record to change the 'current issue' flag of all other records. I don't recommend there usage very often because they are hard to know they are there, but your situation might warrant one.

There are many good articles on how to write a trigger. Here's a few:

http://www.sql-server-performance.com/nn_triggers.asp

http://www.codeproject.com/database/SquaredRomis.asp

http://msdn2.microsoft.com/en-us/library/aa258254(SQL.80).aspx

Good luck!

|||

Many thanks for the help. I'll give those articles some reading.

|||

Okay, so I would put the Trigger in the same store procedure as the Insert or Update store procedure, correct?

|||

No, it's written seperately as an Action against a certain table.

CREATE TRIGGER reminder
ON titles
FOR INSERT, UPDATE

'Reminder' is the name of the trigger

'titles' is the name of the table

"FOR INSERT, UPDATE" is the action

Make sure and look at that last link I sent you as far as the details are concerned.

|||

Okay, so the Trigger is created in its own separate store procedure. How about the insert or update query? Does it has to be a store procedure for the trigger to work? Right now many of my insert and update quries are from code behind at run time. And one more thing, although the Trigger is written as a store procedure but I do not have to call it, correct? It will automatically detect any upates or insert, right?

|||

You're correct, the Trigger will just run when one of these actions on the table has ocurred. Your insert code happen by stored procedure or by manually inserting a row into the table. It doesn't matter how the Insert happens, it just knows to run when one does occur.

|||

Thanks so much! I'll give Trigger a try now.

How do I make Field_B and Field_G to look at Field_A?

My Current Table
Field_A Field_B Field_G
100 Memo Memo
-50 Memo Memo
200 Memo Memo
-100 Memo Memo
How do I make my Field_B and Field_G to Reference/Evaluate Field_A
For Example: If Field_A > 0 then Field_B and Field_G = Debit Memo
If Field_A < 0 then Field_B and Field_G = Credit Memo
I would like to see the result in this Format
Field_A Field_B Field_G
100 Debit Memo Debit Memo
-50 Credit Memo Credit Memo
200 Debit Memo Debit Memo
-100 Credit Memo Credit Memo
Thanks,
JohnYou can create calculated fields.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSCREATE/htm/rcr_creating_structure_objects_v1_8i44.asp
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"John" <John@.discussions.microsoft.com> wrote in message
news:01D9F330-83C3-4E1E-9C3F-002633E38129@.microsoft.com...
> My Current Table
> Field_A Field_B Field_G
> 100 Memo Memo
> -50 Memo Memo
> 200 Memo Memo
> -100 Memo Memo
> How do I make my Field_B and Field_G to Reference/Evaluate Field_A
> For Example: If Field_A > 0 then Field_B and Field_G = Debit Memo
> If Field_A < 0 then Field_B and Field_G = Credit Memo
> I would like to see the result in this Format
> Field_A Field_B Field_G
> 100 Debit Memo Debit Memo
> -50 Credit Memo Credit Memo
> 200 Debit Memo Debit Memo
> -100 Credit Memo Credit Memo
> Thanks,
> John

Monday, March 26, 2012

How do I know if I need SQL SP3 or 3A?

My verions of SQL is 8.00194 (RTM) Does this mean I am current. How would
I
go about finding our if I need a service pack installed or not?
--
MandyHYou're not current. I personally would install the latest service pack
(SP3A).
Your SQL Server is currently open to security risks which, along with
patches, the service pack addresses.
"MandyHancock" <MandyHancock@.discussions.microsoft.com> wrote in message
news:D1314878-A73E-4926-8A9A-93E808C06A05@.microsoft.com...
> My verions of SQL is 8.00194 (RTM) Does this mean I am current. How
would I
> go about finding our if I need a service pack installed or not?
> --
> MandyH|||Please review the ProductLevel option of the serverproperty() function.
You'll find more details in Books Online...
this will tell you what service pack you have. RTM means released to
manufacturing and means it's the initial release of SQL 2000 with no service
packs. You are currently exposed to a LARGE number of security and other
problems.
Brian Moran
Principal Mentor
Solid Quality Learning
SQL Server MVP
http://www.solidqualitylearning.com
"MandyHancock" <MandyHancock@.discussions.microsoft.com> wrote in message
news:D1314878-A73E-4926-8A9A-93E808C06A05@.microsoft.com...
> My verions of SQL is 8.00194 (RTM) Does this mean I am current. How
would I
> go about finding our if I need a service pack installed or not?
> --
> MandyH|||Okay, thanks very much
"Brian Moran" wrote:

> Please review the ProductLevel option of the serverproperty() function.
> You'll find more details in Books Online...
> this will tell you what service pack you have. RTM means released to
> manufacturing and means it's the initial release of SQL 2000 with no servi
ce
> packs. You are currently exposed to a LARGE number of security and other
> problems.
> --
> Brian Moran
> Principal Mentor
> Solid Quality Learning
> SQL Server MVP
> http://www.solidqualitylearning.com
>
> "MandyHancock" <MandyHancock@.discussions.microsoft.com> wrote in message
> news:D1314878-A73E-4926-8A9A-93E808C06A05@.microsoft.com...
> would I
>
>|||Okay. Thanks very much
"Armando Prato" wrote:

> You're not current. I personally would install the latest service pack
> (SP3A).
> Your SQL Server is currently open to security risks which, along with
> patches, the service pack addresses.
>
> "MandyHancock" <MandyHancock@.discussions.microsoft.com> wrote in message
> news:D1314878-A73E-4926-8A9A-93E808C06A05@.microsoft.com...
> would I
>
>

How do I know if I need SQL SP3 or 3A?

My verions of SQL is 8.00194 (RTM) Does this mean I am current. How would I
go about finding our if I need a service pack installed or not?
MandyH
You're not current. I personally would install the latest service pack
(SP3A).
Your SQL Server is currently open to security risks which, along with
patches, the service pack addresses.
"MandyHancock" <MandyHancock@.discussions.microsoft.com> wrote in message
news:D1314878-A73E-4926-8A9A-93E808C06A05@.microsoft.com...
> My verions of SQL is 8.00194 (RTM) Does this mean I am current. How
would I
> go about finding our if I need a service pack installed or not?
> --
> MandyH
|||Please review the ProductLevel option of the serverproperty() function.
You'll find more details in Books Online...
this will tell you what service pack you have. RTM means released to
manufacturing and means it's the initial release of SQL 2000 with no service
packs. You are currently exposed to a LARGE number of security and other
problems.
Brian Moran
Principal Mentor
Solid Quality Learning
SQL Server MVP
http://www.solidqualitylearning.com
"MandyHancock" <MandyHancock@.discussions.microsoft.com> wrote in message
news:D1314878-A73E-4926-8A9A-93E808C06A05@.microsoft.com...
> My verions of SQL is 8.00194 (RTM) Does this mean I am current. How
would I
> go about finding our if I need a service pack installed or not?
> --
> MandyH
|||Okay, thanks very much
"Brian Moran" wrote:

> Please review the ProductLevel option of the serverproperty() function.
> You'll find more details in Books Online...
> this will tell you what service pack you have. RTM means released to
> manufacturing and means it's the initial release of SQL 2000 with no service
> packs. You are currently exposed to a LARGE number of security and other
> problems.
> --
> Brian Moran
> Principal Mentor
> Solid Quality Learning
> SQL Server MVP
> http://www.solidqualitylearning.com
>
> "MandyHancock" <MandyHancock@.discussions.microsoft.com> wrote in message
> news:D1314878-A73E-4926-8A9A-93E808C06A05@.microsoft.com...
> would I
>
>
|||Okay. Thanks very much
"Armando Prato" wrote:

> You're not current. I personally would install the latest service pack
> (SP3A).
> Your SQL Server is currently open to security risks which, along with
> patches, the service pack addresses.
>
> "MandyHancock" <MandyHancock@.discussions.microsoft.com> wrote in message
> news:D1314878-A73E-4926-8A9A-93E808C06A05@.microsoft.com...
> would I
>
>

How do I know if I need SQL SP3 or 3A?

My verions of SQL is 8.00194 (RTM) Does this mean I am current. How would I
go about finding our if I need a service pack installed or not?
--
MandyHYou're not current. I personally would install the latest service pack
(SP3A).
Your SQL Server is currently open to security risks which, along with
patches, the service pack addresses.
"MandyHancock" <MandyHancock@.discussions.microsoft.com> wrote in message
news:D1314878-A73E-4926-8A9A-93E808C06A05@.microsoft.com...
> My verions of SQL is 8.00194 (RTM) Does this mean I am current. How
would I
> go about finding our if I need a service pack installed or not?
> --
> MandyH|||Please review the ProductLevel option of the serverproperty() function.
You'll find more details in Books Online...
this will tell you what service pack you have. RTM means released to
manufacturing and means it's the initial release of SQL 2000 with no service
packs. You are currently exposed to a LARGE number of security and other
problems.
--
Brian Moran
Principal Mentor
Solid Quality Learning
SQL Server MVP
http://www.solidqualitylearning.com
"MandyHancock" <MandyHancock@.discussions.microsoft.com> wrote in message
news:D1314878-A73E-4926-8A9A-93E808C06A05@.microsoft.com...
> My verions of SQL is 8.00194 (RTM) Does this mean I am current. How
would I
> go about finding our if I need a service pack installed or not?
> --
> MandyH|||Okay, thanks very much
"Brian Moran" wrote:
> Please review the ProductLevel option of the serverproperty() function.
> You'll find more details in Books Online...
> this will tell you what service pack you have. RTM means released to
> manufacturing and means it's the initial release of SQL 2000 with no service
> packs. You are currently exposed to a LARGE number of security and other
> problems.
> --
> Brian Moran
> Principal Mentor
> Solid Quality Learning
> SQL Server MVP
> http://www.solidqualitylearning.com
>
> "MandyHancock" <MandyHancock@.discussions.microsoft.com> wrote in message
> news:D1314878-A73E-4926-8A9A-93E808C06A05@.microsoft.com...
> > My verions of SQL is 8.00194 (RTM) Does this mean I am current. How
> would I
> > go about finding our if I need a service pack installed or not?
> > --
> > MandyH
>
>|||Okay. Thanks very much
"Armando Prato" wrote:
> You're not current. I personally would install the latest service pack
> (SP3A).
> Your SQL Server is currently open to security risks which, along with
> patches, the service pack addresses.
>
> "MandyHancock" <MandyHancock@.discussions.microsoft.com> wrote in message
> news:D1314878-A73E-4926-8A9A-93E808C06A05@.microsoft.com...
> > My verions of SQL is 8.00194 (RTM) Does this mean I am current. How
> would I
> > go about finding our if I need a service pack installed or not?
> > --
> > MandyH
>
>

How do I jump to another report based on a value in my current report? report has no parameters.

How do I jump to another report based on a value in my current report. The report that I am jumping from has no parameters, just values.

Hello,

Does your target report have parameters? For example, you want to go to the target report and run it with the value you selected on the current report?

Or are you saying... If the field value is between a and b, go to report 1, if it's between b and c, go to report 2, otherwise go to report 3.

Can you explain a little more about your situation?

Jarret

|||

the report I am jumping from has no parameters. I want to be able to click on a value and have it jump to another report. That report possibly being jumped too might or might not have parameters.

I just used the following expression and it works to a degree, but it enables all the values in the column for jumping, rather than just the report I want

=iif(Fields!YN_DESC.Value="A","Report 1","Report2")

|||

Sorry for the delay...

This will only enable the "A" values to jump to a report (Report 1), any other values will not have the jump to enabled.

=Switch(Fields!YN_Desc.Value = "A", "Report 1")

If you need to add additional conditions... Example, if the value is "C" - Report 31, "D" - Report 7.

=Switch(Fields!YN_Desc.Value = "A", "Report 1",
Fields!YN_Desc.Value = "C", "Report 31",
Fields!YN_Desc.Value = "D", "Report 7")

Hope this helps.

Jarret

How do I jump to another report based on a value in my current report? report has no parameters.

How do I jump to another report based on a value in my current report. The report that I am jumping from has no parameters, just values.

Hello,

Does your target report have parameters? For example, you want to go to the target report and run it with the value you selected on the current report?

Or are you saying... If the field value is between a and b, go to report 1, if it's between b and c, go to report 2, otherwise go to report 3.

Can you explain a little more about your situation?

Jarret

|||

the report I am jumping from has no parameters. I want to be able to click on a value and have it jump to another report. That report possibly being jumped too might or might not have parameters.

I just used the following expression and it works to a degree, but it enables all the values in the column for jumping, rather than just the report I want

=iif(Fields!YN_DESC.Value="A","Report 1","Report2")

|||

Sorry for the delay...

This will only enable the "A" values to jump to a report (Report 1), any other values will not have the jump to enabled.

=Switch(Fields!YN_Desc.Value = "A", "Report 1")

If you need to add additional conditions... Example, if the value is "C" - Report 31, "D" - Report 7.

=Switch(Fields!YN_Desc.Value = "A", "Report 1",
Fields!YN_Desc.Value = "C", "Report 31",
Fields!YN_Desc.Value = "D", "Report 7")

Hope this helps.

Jarret

How do I jump to another report based on a value

How do I jump to another report based on a value in my current report?

Right-click on the field you wish to link, select Navigation, select jump to report, and specify the report and any parameters required.

Here are a couple of links that may help.

http://msdn2.microsoft.com/en-us/library/aa964132.aspx

http://www.codeproject.com/useritems/InputParmReport.asp?df=100&forumid=290297&exp=0&select=1472409

cheers,

Andrew

|||

Thanks Andrew,

The examples that you gave me are based on parameters. I made a mistake. What I actually need is to be able to jump to a

report based on a value in one of the report columns. The report that I am jumping from has no parameters and is just a table with

columns and values. How can I do this?

|||

Hi,

you can use the hyperlink action "jump to report" using an expression like this:

=IIf(Logical_Expression, "reportname 1", "reportname 2")

Best regards

Sven

|||

Hi Sven

I tried doing this and it jumps to the report. The problem I am encountering is that the whole column is being enabled to jump rather than just the selected being enabled when the user passes his cursour over it. How do I enable just that value and not all the column values?

|||Hi,
then you have to use the switch-function instead of the iif-function.
=switch(Logical_Expression, "reportname")
br
Sven

Monday, March 12, 2012

How do I format zeros (0) to display as dashes (-)?

I am using the current formula and it works. #,###,;(#,###,) How do change
this formula to display the zeros as dashes?
Thanks in AdvanceUse the below expression
=Iif(Fields!Measures_TxnCount.Value=0,'-',
Fields!Measures_TxnCount.Value)
I hope this should solve u r problem
OriginalStealth wrote:
> I am using the current formula and it works. #,###,;(#,###,) How do
change
> this formula to display the zeros as dashes?
>
> Thanks in Advance

how do I force connections to close before detaching a DB

Hi,
I need to detach a DB, but need to force any current connections to be
disconnected as I am getting an error saying that I cannot detach the DB as
it is being used.
What is the best way of doing this?
I am using DMO to detach at the moment.
ThanksALTER DATABASE dbname SET SINGLE_USER WITH ROLLBACK IMMEDIATE
(Why are you detaching the database? Why are you detaching a database that
is in use?)
"Jason Fischer" <jason.fischer@.micropay.com.au> wrote in message
news:OTM174ZkFHA.1948@.TK2MSFTNGP12.phx.gbl...
> Hi,
> I need to detach a DB, but need to force any current connections to be
> disconnected as I am getting an error saying that I cannot detach the DB
> as it is being used.
> What is the best way of doing this?
> I am using DMO to detach at the moment.
> Thanks
>

Friday, March 9, 2012

How do I find the highest Unique Identifier?

I'd like to know the current value of my uniqueID column before I
create a new record.

Is there a way to find out this value?
It is numeric in my case, but I can't just look for the MAX value,
since some records may have been deleted, and the value for the
uniqueID still stays at the higher value.

Is there a way to read this internally kept value?Stacey,

It sounds like you are using an IDENTITY column; if that's the case,
then you can use IDENT_CURRENT to find the last generated IDENTITY
value.

HTH,
Stu|||Let's get back to the basics of an RDBMS. Rows are not records; fields
are not columns; tables are not files. I hope you know never to use
IDENTITY as a key.|||Stu - Thanks!
That was exactly what I was looking for!

And CELKO - I'm sure everybody reading this thread will appreciate your
useful contribution...|||Do NOT assume that the next IDENTITY value will equal IDENT_CURRENT +
1. In a multi-user system you cannot reliably predict the next IDENTITY
value to be inserted. Nor should it be necessary to do so.

Stacey, if you explain your requirement fully I'm sure we can help you
with a better solution.

--
David Portas
SQL Server MVP
--|||Stu (stuart.ainsworth@.gmail.com) writes:
> It sounds like you are using an IDENTITY column; if that's the case,
> then you can use IDENT_CURRENT to find the last generated IDENTITY
> value.

But beware of that IDENT_CURRENT is not safe from other processes. That is,
if you call IDENT_CURRENT before you insert a row, and the call
scope_identity() to see what you actually got, they may not be the same.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Wednesday, March 7, 2012

How do I Filter by Current Date

I have used 'GETDATE()' but it appears to ignore the current date
because the data does nor have any time information in it. How do I get
filter the data just by date?
Regards
Colin
*** Sent via Developersdex http://www.examnotes.net ***Select *
From TableName
Where DateColumn = Cast(DateDiff(d, 0, Current_Timestamp) As DateTime)
Thomas
"Colin Spalding" <pupil@.alottolearn.com> wrote in message
news:eRPb0%23FZFHA.3164@.TK2MSFTNGP09.phx.gbl...
>I have used 'GETDATE()' but it appears to ignore the current date
> because the data does nor have any time information in it. How do I get
> filter the data just by date?
> Regards
> Colin
> *** Sent via Developersdex http://www.examnotes.net ***|||Colin Spalding wrote:
> I have used 'GETDATE()' but it appears to ignore the current date
> because the data does nor have any time information in it. How do I
> get filter the data just by date?
> Regards
> Colin
> *** Sent via Developersdex http://www.examnotes.net ***
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"|||Colin Spalding wrote:
> I have used 'GETDATE()' but it appears to ignore the current date
> because the data does nor have any time information in it. How do I
> get filter the data just by date?
>
If you're storing time as well as date, then use greater than and less than:
WHERE datefield >= GETDATE() and datefield < dateadd(d,1,GETDATE())
Bob Barrows
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"|||Bob,
My guess is that you typed in getdate(), but meant @.d, where
@.d is a date-only value that has the date required, and what you
ended up suggesting was an uncommon requirement: rows with [datefield]
some time in the 24 hour interval starting right this instant? If the
datefield values are all timestamped midnight, it will give the rows
from tomorrow, and otherwise, it may not be reproducible.
If "today" is needed, one solution is this:
where datefield >= dateadd(d,datediff(day,0,getdate()),0)
and datefield < dateadd(d,datediff(day,0,getdate()),1)
Steve Kass
Drew University
Bob Barrows [MVP] wrote:

>Colin Spalding wrote:
>
>If you're storing time as well as date, then use greater than and less than
:
>WHERE datefield >= GETDATE() and datefield < dateadd(d,1,GETDATE())
>Bob Barrows
>
>|||Steve Kass wrote:
> Bob,
>
> My guess is that you typed in getdate(), but meant @.d, where
> @.d is a date-only value that has the date required,
Yes. My bad
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"|||Or alternatively (rather than the date calculations),
WHERE CONVERT(char(8),datefield,112) = CONVERT(char(8),GETDATE(),112)
as the 112 conversion style, will drop the time info and format the date
in an unambiguous format.
*mike hodgson* |/ database administrator/ | mallesons stephen jaques
*T* +61 (2) 9296 3668 |* F* +61 (2) 9296 3885 |* M* +61 (408) 675 907
*E* mailto:mike.hodgson@.mallesons.nospam.com |* W* http://www.mallesons.com
Bob Barrows [MVP] wrote:

>Steve Kass wrote:
>
>Yes. My bad
>

Friday, February 24, 2012

How do I do this?

In my DB I have inadvertantly dropped a table. I do however have a backup. How can I get a copy of the (1) table from my backup DB to my current DB?Restore the backup and copy the table to your database, If there are no indexes and complex objects you can do SELECT INTO, SQL Server will create a simple table in your database. The other option create a new table with same name and copy the data from the restored database. Run a search for INTO in the BOL. Hope this helps.|||

Jim:

Create an empty database and restore your database to the newly created empty database. Then run the DDL to re-create the table in your old database and then copy the data from the restored database to the old database. Once you are satisfied that the old table is ok, drop the restored database.

[ Obvioulsy, I agree with Caddre. :-) ]

|||Thanks, here is the part I am missing. what is the syntax for going from one DB to another

i.e.

SELECT * INTO CurrentDB.NewTable FROM BackupDB.ExistingTable|||

Try this

SELECT * INTO CurrentDB.dbo.Newtable FROM BackupDB.dbo.ExistingTable

|||

SQL Server uses a 'four-part' naming convention. It follows this pattern:

Server.Database.schema.table

In 'normal' use, if you supply just the table name,

the 'schema' is assumed to be either the default user/owner or schema, the database is the current connected database, and the server is the current connected server.|||Thanks! That is exactly what I was looking for, issue resolved!

Sunday, February 19, 2012

How do I determine the current retention period for merge publicat

How do I determine the current retention period for merge publication ?
Nevermind I have found it.
"Russell" wrote:

> How do I determine the current retention period for merge publication ?