Showing posts with label table. Show all posts
Showing posts with label table. Show all posts

Friday, March 30, 2012

how to excluded the intersection of 2 dimensions ?

Hi,

I have the following simplified problem.

I have a fact table and two dimension tables, colors and weekdays.

I can make a query to select all except red and all except on monday but I like to make a query to select all except red mondays ?

They query tool doesn't give you really the options.

Any suggestions ?

Constantijn Enders

You can do it in MDX, but only a few query tools will allow you to construct queries like this. I think vendors tend to refer to this capability as 'asymmetic sets'; I can only think of one tool I've seen recently that did this (Intelligencia - http://www.it-workplace.co.uk/i4wfeatures.aspx) but I'm sure that if you hunt around there will be others. Does anyone else know of one?

Here's an MDX query to prove it's possible:

select

measures.[internet sales amount] on 0,

except(

[Date].[Day Name].[Day Name].members

*

[Product].[Color].[Color].members

,{([Date].[Day Name].&[2], [Product].[Color].&[Red])}

) on 1

from [Adventure Works]

HTH,

Chris

How to exclude the collation property when scripting a table in SQL Server 2005

In Sequel Server 2000 when I used to script the creation of a table, it was
possible to go to the scripting options in SQL Query Analyser and switch off
the Include Collation statements.
However, I cannot seem to find this setting in SQL Server 2005 - can anyone
point me in the right direction as I do not want to include these statements
when I create a CREATE TABLE script.
Thanks in advance
AndyHi Andrew
If you use the scripting wizard there are configurable options that by
default do not include collations. Try right clicking on the management
branch rather than the table and choose the General Scripts option.
John
"Andrew Houghton" wrote:
> In Sequel Server 2000 when I used to script the creation of a table, it was
> possible to go to the scripting options in SQL Query Analyser and switch off
> the Include Collation statements.
> However, I cannot seem to find this setting in SQL Server 2005 - can anyone
> point me in the right direction as I do not want to include these statements
> when I create a CREATE TABLE script.
> Thanks in advance
> Andy
>
>

Wednesday, March 28, 2012

how to enumerate all table in db??

how to enumerate all table with a column name in sqlserver db?This returns all objects with a given column name:

--------------
declare @.SearchColumn varchar(50)
set @.SearchColumn = 'Database_ID'

select sysobjects.name as ObjectName,
sysobjects.xtype as ObjectType
from sysobjects
inner join syscolumns on sysobjects.id = syscolumns.id
where syscolumns.name = @.SearchColumn
--------------

If you want just tables, filter for sysobjects.xtype = 'U'

How to enter more number of rows in a table having more number of columns at a time

Hi

I want to enter rows into a table having more number of columns
For example : I have one employee table having columns (name ,address,salary etc )
then, how can i enter 100 employees data at a time ?

Suppose i am having my data in .txt file (or ) in .xls

( SQL Server 2005)

Hi,

Where is the data coming from ? If you have all these information in a flat file, then Bulk insert will do it faster.

~mohan

sql

How to enter manually a "uniqueIdentifier" type value

I created a DB and a table in Visual Studio .NET 2003. For one of the column
I choose the data type uniqueidentifier.
How can I add manually a unique ID value in the table value editor?
OK, figured it out: select newID() as the default value.
"Frank" <someone@.nospam.com> wrote in message
news:c5f6j4$dpe$1@.news.mch.sbs.de...
> I created a DB and a table in Visual Studio .NET 2003. For one of the
column
> I choose the data type uniqueidentifier.
> How can I add manually a unique ID value in the table value editor?
>

How to ensure the rest of the records will be inserted even if there is an error

Hi,
I have a sql statement that perform bulk insert into another table.
How can I ensure that if an error occurs, maybe due to primary key
constraint, the rest of the records will be inserted.
Thanks alot.Hi
Take a look at this example, even this transaction will generate a violation
of primary key constraint the rest of the data will be inserted
Please read SET ARITHABORT commant in the BOL to get a whole picture
create table #t (col int not null primary key)
begin tran
insert into #t values (1)
insert into #t values (2)
insert into #t values (3)
insert into #t values (3)
insert into #t values (4)
insert into #t values (5)
commit
select * from #t
drop table #t
"Shelby" <shelby@.singnet.com.sg> wrote in message
news:%23X6PcA6XGHA.3868@.TK2MSFTNGP04.phx.gbl...
> Hi,
> I have a sql statement that perform bulk insert into another table.
> How can I ensure that if an error occurs, maybe due to primary key
> constraint, the rest of the records will be inserted.
> Thanks alot.
>
>
>|||That depends on the type of error that occures. Fatal Errrors for
example will always abort the entire procedure and rollback all
transactions. There might be a way for non-fatal errors using if-blocks
like
if @.err<>0
// do something else with the datasql

How to ensure data is no longer on disk

I have a table with some sensitive customer data in it. I am now
keeping all the data in another table, and encrypting it. I want to
get rid of the original unencrypted data and be sure that it is no
longer anywhere on disk. Should I drop the table, or first delete the
rows and then do a dump tran? I'm not sure how to know if the data is
actually physically deleted from disk, or if it's still there, but
just in blocks that get marked as available. Any guidance would be
greatly appreciated.

Thanks,
Brucesandell@.pacbell.net (Bruce) wrote in message news:<595024a5.0405061512.13a1c5f1@.posting.google.com>...
> I have a table with some sensitive customer data in it. I am now
> keeping all the data in another table, and encrypting it. I want to
> get rid of the original unencrypted data and be sure that it is no
> longer anywhere on disk. Should I drop the table, or first delete the
> rows and then do a dump tran? I'm not sure how to know if the data is
> actually physically deleted from disk, or if it's still there, but
> just in blocks that get marked as available. Any guidance would be
> greatly appreciated.
> Thanks,
> Bruce

It depends how serious you are about getting rid of the unencrypted
data. You could add a new physical disk to the server, create a new
empty database on it, copy over all the data except the unencrypted
data, then remove the existing disk and format it and/or overwrite the
sectors with a suitable low-level disk tool.

If that is overkill for your needs, you could UPDATE all the
unencrypted data to something meaningless and then checkpoint the
database, which should overwrite the current pages on disk. You could
then DELETE the rows, and delete any transaction log backup files
(assuming you don't need them for recovery).

Don't forget that the unencrypted data may still exist in database
backups, so you would need to address that issue also.

Simon

How to enrypt password in a table?

Hi,
I use SQL 2K and have a table "tblPassword" which stores all the username
and passwords for front end login validation. I want to encrypt these table
so only "sa" can read. How can I accomplish this ?
Thanks
kaiHi
Not in SQL Server 2000. Get an application to do it and look at it though
the application.
Regards-
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"kai" <kailiang@.earthlink.net> wrote in message
news:J_PHe.1993$ns.1635@.newsread1.news.atl.earthlink.net...
> Hi,
> I use SQL 2K and have a table "tblPassword" which stores all the username
> and passwords for front end login validation. I want to encrypt these
> table so only "sa" can read. How can I accomplish this ?
> Thanks
> kai
>|||Hi,
Have a look into the below URL.
http://www.activecrypt.com/help/xpc...tep_by_step.htm
Thanks
Hari
SQL Server MVP
"kai" <kailiang@.earthlink.net> wrote in message
news:J_PHe.1993$ns.1635@.newsread1.news.atl.earthlink.net...
> Hi,
> I use SQL 2K and have a table "tblPassword" which stores all the username
> and passwords for front end login validation. I want to encrypt these
> table so only "sa" can read. How can I accomplish this ?
> Thanks
> kai
>|||Hi, Mike
Thanks.
Kai
"Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
news:OMAl6q5lFHA.2860@.TK2MSFTNGP15.phx.gbl...
> Hi
> Not in SQL Server 2000. Get an application to do it and look at it though
> the application.
> Regards-
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> IM: mike@.epprecht.net
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
> "kai" <kailiang@.earthlink.net> wrote in message
> news:J_PHe.1993$ns.1635@.newsread1.news.atl.earthlink.net...
>|||Hari,
Thanks for the link. Where I can find
master..xp_sha1
Thanks
Kai
"Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
news:u74DSv5lFHA.3316@.TK2MSFTNGP14.phx.gbl...
> Hi,
> Have a look into the below URL.
> http://www.activecrypt.com/help/xpc...tep_by_step.htm
> Thanks
> Hari
> SQL Server MVP
> "kai" <kailiang@.earthlink.net> wrote in message
> news:J_PHe.1993$ns.1635@.newsread1.news.atl.earthlink.net...
>

How to enhance the performance of a table

hi i have table with around 15 fields and has a pk.
there're some web applications will insert records into it. there're some
backgroup application will query the table.
now, i have around 1000 thousand records, but the there're some locking
behaviour, and even i go query analyzer and do simple query search, i have
the timeout error.
how can i simply improve the performance of it?
thanks!
mullinHi,
how can i simply improve the performance of it?
Create Indexes based on the Where clause of your query. This will definetely
speed up your queries.
How to reduce locks:
1. Create necessary indexes
2. Make the transaction as short as possible.
3. Might be I/O bottle neck.
Whenever your server experiences an I/O bottleneck, the longer it takes
user's transactions to complete.
And the longer they take to complete, the longer locks must be held, which
can lead to other transactions
having to wait for previous locks to be released.
Thanks
Hari
MCDBA
"Mullin Yu" <mullin_yu@.ctil.com> wrote in message
news:uqbTi72JEHA.2576@.TK2MSFTNGP12.phx.gbl...
> hi i have table with around 15 fields and has a pk.
> there're some web applications will insert records into it. there're some
> backgroup application will query the table.
> now, i have around 1000 thousand records, but the there're some locking
> behaviour, and even i go query analyzer and do simple query search, i have
> the timeout error.
> how can i simply improve the performance of it?
> thanks!
> mullin
>

How to enhance the performance of a table

hi i have table with around 15 fields and has a pk.
there're some web applications will insert records into it. there're some
backgroup application will query the table.
now, i have around 1000 thousand records, but the there're some locking
behaviour, and even i go query analyzer and do simple query search, i have
the timeout error.
how can i simply improve the performance of it?
thanks!
mullinHi,
how can i simply improve the performance of it?
Create Indexes based on the Where clause of your query. This will definetely
speed up your queries.
How to reduce locks:
1. Create necessary indexes
2. Make the transaction as short as possible.
3. Might be I/O bottle neck.
Whenever your server experiences an I/O bottleneck, the longer it takes
user's transactions to complete.
And the longer they take to complete, the longer locks must be held, which
can lead to other transactions
having to wait for previous locks to be released.
Thanks
Hari
MCDBA
"Mullin Yu" <mullin_yu@.ctil.com> wrote in message
news:uqbTi72JEHA.2576@.TK2MSFTNGP12.phx.gbl...
> hi i have table with around 15 fields and has a pk.
> there're some web applications will insert records into it. there're some
> backgroup application will query the table.
> now, i have around 1000 thousand records, but the there're some locking
> behaviour, and even i go query analyzer and do simple query search, i have
> the timeout error.
> how can i simply improve the performance of it?
> thanks!
> mullin
>

How to enhance the performance of a table

hi i have table with around 15 fields and has a pk.
there're some web applications will insert records into it. there're some
backgroup application will query the table.
now, i have around 1000 thousand records, but the there're some locking
behaviour, and even i go query analyzer and do simple query search, i have
the timeout error.
how can i simply improve the performance of it?
thanks!
mullin
Hi,
how can i simply improve the performance of it?
Create Indexes based on the Where clause of your query. This will definetely
speed up your queries.
How to reduce locks:
1. Create necessary indexes
2. Make the transaction as short as possible.
3. Might be I/O bottle neck.
Whenever your server experiences an I/O bottleneck, the longer it takes
user's transactions to complete.
And the longer they take to complete, the longer locks must be held, which
can lead to other transactions
having to wait for previous locks to be released.
Thanks
Hari
MCDBA
"Mullin Yu" <mullin_yu@.ctil.com> wrote in message
news:uqbTi72JEHA.2576@.TK2MSFTNGP12.phx.gbl...
> hi i have table with around 15 fields and has a pk.
> there're some web applications will insert records into it. there're some
> backgroup application will query the table.
> now, i have around 1000 thousand records, but the there're some locking
> behaviour, and even i go query analyzer and do simple query search, i have
> the timeout error.
> how can i simply improve the performance of it?
> thanks!
> mullin
>

How to enfore a primary key range ??

I've inherited the following situation...
The table contains 4 columns... script below
Note that the first 3 columns denote the primary Key...
Actually what is really meant is the following...
Let's say the values for one row are as follows...
Code= A
LowVal = 25
HighVal=50
UseThis=Fred
What they want to be implied by this row... if Code=A and the test val is
between 25 and 50 UseThis= Fred
They want to disallow any row that overlaps from being added... such as the
following...
Code= A
LowVal = 30
HighVal=40
UseThis=Joe
How can you enforce something like this ?
CREATE TABLE [dbo].[Table1] (
[Code] [char] (10) COLLATE Latin1_General_BIN NOT NULL ,
[LowVal] [decimal](6, 0) NOT NULL ,
[HighVal] [decimal](6, 0) NOT NULL ,
[UseThis] [char] (10) COLLATE Latin1_General_BIN NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Table1] ADD
CONSTRAINT [PK_Table1] PRIMARY KEY CLUSTERED
(
[Code],
[LowVal],
[HighVal]
) ON [PRIMARY]"Rob" <rwchome@.comcast.net> wrote in message
news:l4WdnX_h78I-eyzeRVn-vA@.comcast.com...
> I've inherited the following situation...
> The table contains 4 columns... script below
> Note that the first 3 columns denote the primary Key...
> Actually what is really meant is the following...
> Let's say the values for one row are as follows...
> Code= A
> LowVal = 25
> HighVal=50
> UseThis=Fred
> What they want to be implied by this row... if Code=A and the test val is
> between 25 and 50 UseThis= Fred
> They want to disallow any row that overlaps from being added... such as
> the following...
> Code= A
> LowVal = 30
> HighVal=40
> UseThis=Joe
> How can you enforce something like this ?
>
> CREATE TABLE [dbo].[Table1] (
> [Code] [char] (10) COLLATE Latin1_General_BIN NOT NULL ,
> [LowVal] [decimal](6, 0) NOT NULL ,
> [HighVal] [decimal](6, 0) NOT NULL ,
> [UseThis] [char] (10) COLLATE Latin1_General_BIN NULL
> ) ON [PRIMARY]
> GO
> ALTER TABLE [dbo].[Table1] ADD
> CONSTRAINT [PK_Table1] PRIMARY KEY CLUSTERED
> (
> [Code],
> [LowVal],
> [HighVal]
> ) ON [PRIMARY]
>
You'll have to use a trigger for this, eg:
create trigger Table1_no_overlap
on Table1 for insert, update
as
begin
if exists
(
select *
from Table1 l
join Table1 r
on l.LowVal < r.LowVal
and l.HighVal > r.LowVal
)
begin
raiserror('Change would create overlapping range.',16,1)
rollback transaction
end
end
David|||Thanks David,
Maybe I am doing something wrong, but I was able to add the following rows
after applying the trigger...
insert into Table1 Values('A',20,100,'Joe')
insert into Table1 Values('A',20,500,'FRED')
Rob
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:eDxVWD1CGHA.344@.TK2MSFTNGP11.phx.gbl...
> "Rob" <rwchome@.comcast.net> wrote in message
> news:l4WdnX_h78I-eyzeRVn-vA@.comcast.com...
> You'll have to use a trigger for this, eg:
> create trigger Table1_no_overlap
> on Table1 for insert, update
> as
> begin
> if exists
> (
> select *
> from Table1 l
> join Table1 r
> on l.LowVal < r.LowVal
> and l.HighVal > r.LowVal
> )
> begin
> raiserror('Change would create overlapping range.',16,1)
> rollback transaction
> end
> end
>
> David
>|||Hi, Rob
Use the following trigger:
alter trigger Table1_no_overlap
on Table1 for insert, update
as
begin
if exists
(
select *
from Table1 t
join inserted i
on t.LowVal between i.LowVal and i.HighVal
or i.LowVal between t.LowVal and t.HighVal
where i.Code<>t.Code or i.LowVal<>t.LowVal or i.HighVal<>t.HighVal
)
begin
raiserror('Change would create overlapping range.',16,1)
rollback transaction
end
end
If you want to allow overlapping ranges for different codes (but not
for the same code), the trigger would be like this:
alter trigger Table1_no_overlap
on Table1 for insert, update
as
begin
if exists
(
select *
from Table1 t
join inserted i
on t.Code=i.Code and (
t.LowVal between i.LowVal and i.HighVal
or i.LowVal between t.LowVal and t.HighVal
)
where i.LowVal<>t.LowVal or i.HighVal<>t.HighVal
)
begin
raiserror('Change would create overlapping range.',16,1)
rollback transaction
end
end
Razvan|||Rob wrote:

> Thanks David,
> Maybe I am doing something wrong, but I was able to add the following rows
> after applying the trigger...
> insert into Table1 Values('A',20,100,'Joe')
> insert into Table1 Values('A',20,500,'FRED')
> Rob
>
Try it like this. Notice that I've added an extra constraint, modified
the join in the trigger and added CODE to the join. That's my reading
of what you want to achieve. Test carefully.
ALTER TABLE table1 ADD CONSTRAINT ck_table1_lowval_highval
CHECK (lowval <= highval) ;
GO
create trigger Table1_no_overlap
on Table1 for insert, update
as
begin
if exists
(
select *
from Table1 l
join Table1 r
on l.LowVal < r.HighVal
and l.HighVal > r.LowVal
and l.code = r.code
)
begin
raiserror('Change would create overlapping range.',16,1)
rollback transaction
end
end
GO
David Portas
SQL Server MVP
--|||Hi, David
Your trigger doesn't allow any row to be inserted.
Razvan|||Razvan Socol wrote:
> Hi, David
> Your trigger doesn't allow any row to be inserted.
> Razvan
You're right. Here's a correction:
create trigger Table1_no_overlap
on Table1 for insert, update
as
begin
if exists
(
select *
from Table1 l
join Table1 r
on l.LowVal < r.HighVal
and l.HighVal > r.LowVal
and l.code = r.code
and (l.LowVal <> r.LowVal
or l.HighVal <> r.HighVal)
)
begin
raiserror('Change would create overlapping range.',16,1)
rollback transaction
end
end
GO
David Portas
SQL Server MVP
--|||Hi, David
My understanding of the original post is that the following rows are
not allowed (but your trigger allows them):
insert into Table1 Values('A',20,100,'Joe')
insert into Table1 Values('A',100,150,'FRED')
Rob wrote:
> What they want to be implied by this row... if Code=A and the test val is
> between 25 and 50 UseThis= Fred
The following rows would be ok:
insert into Table1 Values('A',20,100,'Joe')
insert into Table1 Values('A',101,150,'FRED')
Razvan|||Thank you both Razvan and David...
Sorry I was not clear on this, actually same HighVal on one row may be equal
to LowVal on another...
The code applied uses > LowVal and <= HighVal...
Rob
"Razvan Socol" <rsocol@.gmail.com> wrote in message
news:1135755688.241085.105660@.g49g2000cwa.googlegroups.com...
> Hi, David
> My understanding of the original post is that the following rows are
> not allowed (but your trigger allows them):
> insert into Table1 Values('A',20,100,'Joe')
> insert into Table1 Values('A',100,150,'FRED')
> Rob wrote:
> The following rows would be ok:
> insert into Table1 Values('A',20,100,'Joe')
> insert into Table1 Values('A',101,150,'FRED')
> Razvan
>|||You might want to add some other constraints. I would not allow the
low and high values to be the same; disjoint ranges will allow you to
use a more readable BETWEEN predicate.
CREATE TABLE Table1
(foo_code CHAR (10) NOT NULL,
low_val DECIMAL(6,0) NOT NULL,
high_val DECIMAL(6,0) NOT NULL,
use_this CHAR (10) DEFAULT '{{ none }}' NOT NULL,
CHECK (low_val <= high_val)
PRIMARY KEY (foo_code,low_val, high_val),
UNIQUE (foo_code,low_val),
UNIQUE (foo_code, high_val)
);
Besides not having overlaps, you might want to avoid gaps in the
ranges.
CREATE TRIGGER Table1_No_Gaps
ON Table1 FOR INSERT, UPDATE
AS
BEGIN
IF EXISTS
(SELECT *
FROM Table1 AS T1
GROUP BY T1.foo_code
HAVING MAX(high_val)- MIN(low_val) +1
= SUM(high_val - low_val + 1)
BEGIN
RAISERROR ('Code Range Errors',16,1);
ROLLBACK TRANSACTION;
END;
END;sql

how to enforce a trigger when update for each record when updates several records bulky?

I made a trigger on a table that fires when update happens, the trigger fires when attempting to update a single record (that is normally) but when trying to update several records bulky using one update statement it fires only once either.

My question is, how to enforce firing the trigger for each record when updates bulky? i.e. how to ensure that when I use the following update statement

UPDATE MyTableName SET ColumnName = 5

And there are 10 records that affected; that the trigger would fire 10 times? (I have the fact that it fires only once)

In SQL server, a trigger fires once per statement, not per row and this can not be changed. You must write your trigger to be able to handle a multiple row update. Post your trigger code and likely someone here can help you re-write it to work for multiple row updates.|||Thanks David, your reply was helpfulsql

Monday, March 26, 2012

how to encrypt the password field in SQL table

Hi,

I have a login table with username and password as attributes. I need to encrypt the password using stored procedure and then save it in the database. And also while retrieving the password, decrypt using the same stored procedure and get the original text.

I dont know how to do it in SQL server 2000.

Please help me on this. Its urgent.

Thanks and Regards

Unfortunately, this is not an easy task with SQL 2000.

You will have an easier time if you use the VS.NET's encryption library to encrypt the password, and store the encrypted (hashed) value.

Then retrieve the encrypted value, use the encryption library at the application level to encrypt and match to the stored value.

Otherwise, you will be passing the password as clear text across the 'wires' -which isn't very secure.

|||

ok thanks for the suggestion.

I need to confirm whether the same can be done in SQL server 2005.

If can how to do it?

thanks and regards

|||

SQL Server 2005 has rich encryption capabilities.

However, there are two issues you need to consider about encryption.

Data at rest Data in Transit|||If you cannot rely on the client functionality for en/decrypting the information you will have to buy a third party product for SQL Server 2000 which is in common a extended procedures being able to use cryptographic libraries.

Jens K. Suessmeyer.

http://www.sqlserver2005.de

How to encrypt data - SQL Server 2000

I have a linked table (SQL Server) in a MS Access 2000 mdb
I have a table called tbl_users which contains a pwd field that I would like
to see encrypted when I open the table. I don't want to use the Input mask
property because everyone can remove it.
How can I encrypt that field so it will be in an unreadable format to users?Steph
Don't do it on database side. Encrypt it on the client site
I suggest you to search(Google) for Steve Kass's recomendations for such
problems.
"Steph" <microsoft.public.access.formscoding> wrote in message
news:%23JQLk3TCFHA.3688@.TK2MSFTNGP14.phx.gbl...
> I have a linked table (SQL Server) in a MS Access 2000 mdb
> I have a table called tbl_users which contains a pwd field that I would
like
> to see encrypted when I open the table. I don't want to use the Input
mask
> property because everyone can remove it.
> How can I encrypt that field so it will be in an unreadable format to
users?
>

How to encrypt a column(field in a table) in MS SQL 2000

Hi,
I want to store user-id and passwords in a table in SQL Server. But as passwords are very secure, I want to encrypt them while storing and may be decrypt them when reqd.
How can I achieve this functionality
Thanks
-Sudhakarpublic key encryption. it is not built into sql2k. google it.|||It is unnecessary to decrypt passwords.
Store the encrypted string in the database. When someone submits a passwords for authentication, encrypt it using the same algorithm and compare the results with what is stored in the database.
This is called one-way encryption, and is both much simpler and much more secure than two-way encryption. I have a one-way encryption algorithm you can use if you want it.sql

Wednesday, March 21, 2012

How to enable ansi_nulls on existing table?

Is there any way to enable ansi nulls on an existing table w/o
droppping/creating?
thanks
jim"Jims" <biz@.neocasa.net> wrote in message
news:uQa6wckiGHA.3816@.TK2MSFTNGP02.phx.gbl...
> Is there any way to enable ansi nulls on an existing table w/o
> droppping/creating?
No. ANSI_NULLS is not a table-specific setting.

How to enable and disable the identity

Hello there :-)
Kindly help me find the answer on how to enable and disable the identity of a field on a table via SQL Script?
Thanks :-)SET IDENTITY_INSERT
Allows explicit values to be inserted into the identity column of a table.

Syntax:
SET IDENTITY_INSERT [ database. [ owner. ] ] { table } { ON | OFF }sql

How to eliminate duplicate data

I have a table with 68 columns. If all the columns hold the same value except for one which is a datetime column I want to delete all but one of the duplicate rows. Preferably the latest one but that is not important. Can someone show me how to accomplish this?

You can use the Group By fucntion

SELECT col_a, col_b, col_c From Table GROUP BY col_a, col_b, col_c

If you want the newest date - you can also using HAVING Clause

SELECT col_a, col_b, col_c From Table GROUP BY col_a, col_b, col_c HAVING max(col_date)

WHERE col_a - col_c are the columns with the same data and col_date is your date column

AWAL

|||Is this a easier process if I manually delete them? I just want to view the duplicate data but my problem is that the DateTime column in my table is unique unlike all the other columns with the same values.|||

John -

I'm not quite certain what you mean but if your datetime column is not unique but you want dups of all the other columns just don't group by the datetime column.

AWAL

|||

Assuming that your data isn't too big, you can use a technique like this:

drop table removeDups
go
create table removeDups(
column1 int,
column2 int,
column3 int,
column4 int,
column5 int,
column6 int,
column7 int,
column8 int,
column9 int,
datevalue datetime)

insert removeDups
select 1,1,1,1,1,1,1,1,1,getdate()
waitfor delay '00:00:01'
insert removeDups
select 1,1,1,1,1,1,1,1,1,getdate()
waitfor delay '00:00:01'
insert removeDups
select 1,1,1,1,1,1,1,1,1,getdate()
waitfor delay '00:00:01'

insert removeDups
select 2,2,2,2,2,2,2,2,2,getdate()
waitfor delay '00:00:01'
insert removeDups
select 2,2,2,2,2,2,2,2,2,getdate()
waitfor delay '00:00:01'
insert removeDups
select 3,3,3,3,3,3,3,3,3,getdate()
waitfor delay '00:00:01'


delete from removeDups
where not exists
(select *
from ( select min(dateValue) as dateValue,column1,column2,column3,column4,column5,column6, column7, column8, column9
from removeDups
group by column1,column2,column3,column4,column5,column6, column7, column8, column9) as mins
where mins.dateValue = removeDups.dateValue
and mins.column1 = removeDups.column1
and mins.column2 = removeDups.column2
and mins.column3 = removeDups.column3
and mins.column4 = removeDups.column4
and mins.column5 = removeDups.column5
and mins.column6 = removeDups.column6
and mins.column7 = removeDups.column7
and mins.column8 = removeDups.column8
and mins.column9 = removeDups.column9)

select *
from removeDups

I figure once you finish this process you will probably want to hurt the person who gave you this design, even if it is yourself. Try to identify a key amongst the 68 columns and add a unique constraint so you can never get in this position again :)

Monday, March 19, 2012

How to edit textbox or a cell of table?

Hi everybody!
I've created a report in reporting services and in it i need to have a
dynamic textbox.
Let me describe more.I have two reports ,in first report i have
manegers' names .After that users see first report and manegers'
informations for example their names and saleries , they want to
select manegers on base for example their saleries ,i mean the user
must see informations then decide and select manegers who their
employees will be shown in second report ,in this case i need a
textbox that the user can write Yes or No in it,or checkbox for
multiple select .
After that users select their manegers they can see manegers'
employees in second report.
I need a textbox that has two values (Yes and No) and these values
must be shown in textbox in preview mode to select by users or user
can select Yes or No or checkbox.
Can anybody help me?
ShimaSwhy not just create one report that groups on the managers names and when
the name is clicked the details are shown. This functionality is built in
and easy to do.
another option is to add link on the managers name and when clicked open the
second report by passing the manager's name as a parameter. you won't be
able to do multiple choices though.
<shima.seifolahi@.gmail.com> wrote in message
news:1193114815.518228.133770@.t8g2000prg.googlegroups.com...
> Hi everybody!
> I've created a report in reporting services and in it i need to have a
> dynamic textbox.
> Let me describe more.I have two reports ,in first report i have
> manegers' names .After that users see first report and manegers'
> informations for example their names and saleries , they want to
> select manegers on base for example their saleries ,i mean the user
> must see informations then decide and select manegers who their
> employees will be shown in second report ,in this case i need a
> textbox that the user can write Yes or No in it,or checkbox for
> multiple select .
> After that users select their manegers they can see manegers'
> employees in second report.
> I need a textbox that has two values (Yes and No) and these values
> must be shown in textbox in preview mode to select by users or user
> can select Yes or No or checkbox.
> Can anybody help me?
> ShimaS
>|||I did it ,but i need to select more than one prson in first report,
for one person i don't have any problem
Thanks