|
Michael Potter wrote: Make sure the Primary Key can only contain 1 value using a check constraint:
ALTER TABLE [dbo].[MyTable] WITH CHECK ADD CONSTRAINT [CK_OneRow] CHECK (([Id]=(1)))
That is a very cool way to solve a very strange request. I'll give it a 5.
|
|
|
|
|
Super solution but can't be replicated in other databases like oracle.
Identity is a near equivalent to rowid concept in Oracle but its a dynamic value i.e not a sequence generator . Hence may be Only possible in sql server.
Regards
Sreeni
www.sreenivaskandakuru.com
|
|
|
|
|
If you change the start value of the identity seed (I'm pretty sure this can be done) and truncate the table the hard coded 1 would fail mind you it is a silly request in the first place and I suspect the OP does not even know what you are talking about.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
It may not be as useless as it first appears. I have used this method to hold global variables that are used by more than one application.
|
|
|
|
|
It'd be easier to create a view and be done with it;
CREATE VIEW GlobalSettingsTable AS
SELECT 1 AS ColumnName,
2 AS Nanana,
'C:\Program Files'
|
|
|
|
|
Yes - if your values are constants.
|
|
|
|
|
No, also for dynamic values; you can put sub-selects in there, or even calls to managed code
|
|
|
|
|
Don't get me wrong, I did not consider it useless (even in this idiotic context) just being a pedantic bastard.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi All,
Thanks in advance..
I have an application that gets installed perfectly fine without hasles in win XP etc. and gets connected to the DB.
When I install the application in Win 7, It gets installed fine but gives an exception as mentioned below when tried to connect to the Access Database.
Exception Message: Provider cannot be found.
it may not be properly installed.
Inner Exception: at ADODB.ConnectionClass.Open(String ConnectionString, String UserID, String Password, Int32 Options)
at VersesOnArt.Startup.LinkTables()
Please help me to get out of error. VERY VERY URGENT..
Thank you once again,
Kuchimanchi
|
|
|
|
|
rskuchimanchi wrote: it may not be properly installed.
Is ADO installed? The 32 or the 64-bit version?
rskuchimanchi wrote: VERY VERY URGENT..
No, it ain't. In fact, I'm gonna ignore the rest of the thread.
|
|
|
|
|
Hi,
Not sure it is the right forum...
I'm using VisualStudio 2010 and trying to use schema compare tool to deploy changes from my db project to my database (SQL server 2008).
when trying to deploy the changes I made in my db project I get anexception with the following message:
"Cannot create index. Object 'v_TQ_IFCR_DATA_COVERAGE' was created with the following SET options off: 'ANSI_NULLS, QUOTED_IDENTIFIER'."
If I will go the the index properties,I see that AnsiNulls
and QuatedIdentifiers are set to project default.
When changing those settings to ON I manage to deploy all updates without any exception.
How can I change project default settings?
I have more then 200 different objects(tables,stored procedures,functions,indexes etc.) and I don't want to change the settings of each object.
Anyone?
Thanks,
Eli
|
|
|
|
|
problem solved.
In my schema compare the options if "Ignore AnsiNulls" and
"Ignore QuatedIdentifiers" where checked,so updated AnsiNulls and QuatedIdentifiers settings was not marked as needs to be updated during the schema compare.
Also,I've set AnsiNulls and QuatedIdentifiers default settings
to true in database.sqlsettings file.
|
|
|
|
|
hi all
im trying to export table loan to excel file but i get this error in sql 2008 r2
Msg 7308, Level 16, State 1, Line 2
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode.
my query is
insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=D:\testing.xls;',
'SELECT * FROM [Bankmellat$]') select * from BML.Loan
anyone can help me for fix this problem
thanks regards
|
|
|
|
|
|
i do your solution but i get error and my problem is stable and i get error again.
|
|
|
|
|
What error? The same error? Or another?
Are you on a 64-bit machine?
|
|
|
|
|
yes i get the same error .
yes my machine is 64 bit
|
|
|
|
|
The JET-provider needs to be 64-bit too. Try downloading[^] the newer version.
|
|
|
|
|
Dear seniors,
How I can use case statement in where clause…..
Below query raised syntax error.
@MyeffectiveDate
Select * from Mytable where ((EffectiveDate <= @ MyeffectiveDate AND
CASE WHEN BillingTerminationDate = NULL THEN
(terminationDate is null or BillingTerminationDate > =@ MyeffectiveDate)
ELSE BillingTerminationDate > =@ MyeffectiveDate)
OR IsAdjustment=1)
WHAT EXACLY I WANT
If(BillingTerminationDate is null) then where clause should used ” (terminationDate is null or BillingTerminationDate > =@ MyeffectiveDate)” statement.
Other wise used
BillingTerminationDate > =@ MyeffectiveDate statement.
Waiting for your need full reply.
Thanks in advance.
|
|
|
|
|
digvijay dobhal wrote: BillingTerminationDate = NULL
You can't use = to compare something to NULL ; use Is Null instead.
digvijay dobhal wrote: If BillingTerminationDate is null then ... BillingTerminationDate >= @MyeffectiveDate
If BillingTerminationDate is NULL , then it's not going to be greater than, less than, or equal to anything else.
digvijay dobhal wrote: AND
CASE WHEN BillingTerminationDate = NULL THEN
(terminationDate is null or BillingTerminationDate >= @MyeffectiveDate)
ELSE BillingTerminationDate >= @MyeffectiveDate)
You're missing an END on your CASE block. You also can't use a CASE block like this.
What you want is probably something like this:
WHERE
(
(
EffectiveDate <= @MyeffectiveDate
And
(
(BillingTerminationDate Is Null And TerminationDate Is Null)
Or
BillingTerminationDate >= @MyeffectiveDate
)
)
Or
IsAdjustment = 1
)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks Richard Deeming.
I try above query bur not succeed.
Finally I do increase number of query lines and doing below…..
select * from Mytable where ((EffectiveDate <= @MyeffectiveDate and BillingTerminationDate is not null
and (BillingTerminationDate > =@MyeffectiveDate)) OR IsAdjustment=1)
select * from Mytable where ((EffectiveDate <= @MyeffectiveDate and BillingTerminationDate is null
and (TerminationDate > =@MyeffectiveDate)) OR IsAdjustment=1) Right now its working as my expactation. But having doubt that after reviewing, may or may not it will give me pain.
|
|
|
|
|
OK, try:
WHERE
(
(
EffectiveDate <= @MyEffectiveDate
And
(
(BillingTerminationDate Is Not Null And BillingTerminationDate >= @MyEffectiveDate)
Or
(BillingTerminationDate Is Null And TerminationDate >= @MyEffectiveDate)
)
)
Or
IsAdjustment = 1
)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanx.. its working
|
|
|
|
|
CASE is an expression and not an executable statement.
The general form of the predicate of a WHERE clause is expression operator expression where operator is = or <> or > or < etc.
You can use a case as one of the expressions in the predicate.
But you shouldn't need the case. Try this instead:
Select *
FROM Mytable
WHERE (
BillingTerminationDate is null
AND
terminationDate is null)
OR BillingTerminationDate > =@ MyeffectiveDate and we'll see if I understood you correctly.
People say nothing is impossible, but I do nothing every day.
|
|
|
|
|
digvijay dobhal wrote: Dear seniors,
Thats about the most offensive way ive seen to start a question.
|
|
|
|