Saturday, February 25, 2012

Script

I have a foreign key. I want to script how to create it without using
the management studio i.e. from the query analyser in SQL 2005. Is
there a system stored procedure or something that does this for you.
thanks for your help
NewishNo, you will have to build it like
exec ('alter table [' + @.table + '] drop constraint [' + @.constraint + ']')
from..
Read up this article
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/e960df1a-13fc-43ee-ba91-34c1b719ac2c.htm
"Newish" <ahussain3@.gmail.com> wrote in message
news:1175352912.176014.48640@.q75g2000hsh.googlegroups.com...
>I have a foreign key. I want to script how to create it without using
> the management studio i.e. from the query analyser in SQL 2005. Is
> there a system stored procedure or something that does this for you.
> thanks for your help
> Newish
>|||Here's an example from BOL:
USE AdventureWorks ;
GO
CREATE TABLE Person.ContactBackup
(ContactID int) ;
GO
ALTER TABLE Person.ContactBackup
ADD CONSTRAINT FK_ContactBacup_Contact FOREIGN KEY (ContactID)
REFERENCES Person.Contact (ContactID) ;
ALTER TABLE Person.ContactBackup
DROP CONSTRAINT FK_ContactBacup_Contact ;
GO
DROP TABLE Person.ContactBackup ;
If you want to get the syntax 'for free' you can create the FK in EM and
rather than actually save the change, simply take a look at the script that
is generated. Cheers, Paul Ibison SQL Server MVP,
www.replicationanswers.com

Script

Hi Folks,
I need a script that it'll changed varchar field to nvarchar a table which i
pass it's name via parameter.
I generated it but it'll raise exception when a field has foreign key etc...
I don't want to spend more time to this work. Do you have a script like
this? Or program?
If you have it could you share with me?
Thanks.Hi
If you try and change a column's data type and the column is referenced by a
foreign key, or is part of a primary key will give you an error. You will
need to drop these before trying to change the columns datatype. The easiest
way would be to script them, drop them and re-create them afterwards. To drop
them see http://www.mssqlserver.com/scripts/drop_keys.sql
John
"Erencan SAÃ?IROÃ?LU" wrote:
> Hi Folks,
> I need a script that it'll changed varchar field to nvarchar a table which i
> pass it's name via parameter.
> I generated it but it'll raise exception when a field has foreign key etc...
> I don't want to spend more time to this work. Do you have a script like
> this? Or program?
> If you have it could you share with me?
> Thanks.
>
>|||Thanks John, but i want to foreign keys add again after change data type.
This script just drop foreign keys. :(
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:55E6E65D-A653-4620-A2D3-C4BEB4A224AC@.microsoft.com...
> Hi
> If you try and change a column's data type and the column is referenced by
> a
> foreign key, or is part of a primary key will give you an error. You will
> need to drop these before trying to change the columns datatype. The
> easiest
> way would be to script them, drop them and re-create them afterwards. To
> drop
> them see http://www.mssqlserver.com/scripts/drop_keys.sql
> John
> "Erencan SADIRODLU" wrote:
>> Hi Folks,
>> I need a script that it'll changed varchar field to nvarchar a table
>> which i
>> pass it's name via parameter.
>> I generated it but it'll raise exception when a field has foreign key
>> etc...
>> I don't want to spend more time to this work. Do you have a script like
>> this? Or program?
>> If you have it could you share with me?
>> Thanks.
>>|||Hi
But you could script them first, which is what I indicated in the response.
There are several ways to do this, as this is a one off job use Enterprise
Manager. If you take a backup before making any changes and restore the
database under a different name, you could use a tool such as Red Gate's SQL
Compare to check the differences (in fact you could use this to re-apply the
missing FKs and PKs).
John
"Erencan SAÃ?IROÃ?LU" wrote:
> Thanks John, but i want to foreign keys add again after change data type.
> This script just drop foreign keys. :(
>
> "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> news:55E6E65D-A653-4620-A2D3-C4BEB4A224AC@.microsoft.com...
> > Hi
> >
> > If you try and change a column's data type and the column is referenced by
> > a
> > foreign key, or is part of a primary key will give you an error. You will
> > need to drop these before trying to change the columns datatype. The
> > easiest
> > way would be to script them, drop them and re-create them afterwards. To
> > drop
> > them see http://www.mssqlserver.com/scripts/drop_keys.sql
> >
> > John
> >
> > "Erencan SADIRODLU" wrote:
> >
> >> Hi Folks,
> >> I need a script that it'll changed varchar field to nvarchar a table
> >> which i
> >> pass it's name via parameter.
> >> I generated it but it'll raise exception when a field has foreign key
> >> etc...
> >> I don't want to spend more time to this work. Do you have a script like
> >> this? Or program?
> >>
> >> If you have it could you share with me?
> >> Thanks.
> >>
> >>
> >>
>
>

Script

Hi Folks,
I need a script that it'll changed varchar field to nvarchar a table which i
pass it's name via parameter.
I generated it but it'll raise exception when a field has foreign key etc...
I don't want to spend more time to this work. Do you have a script like
this? Or program?
If you have it could you share with me?
Thanks.Hi
If you try and change a column's data type and the column is referenced by a
foreign key, or is part of a primary key will give you an error. You will
need to drop these before trying to change the columns datatype. The easies
t
way would be to script them, drop them and re-create them afterwards. To dro
p
them see http://www.mssqlserver.com/scripts/drop_keys.sql
John
"Erencan SADIRODLU" wrote:

> Hi Folks,
> I need a script that it'll changed varchar field to nvarchar a table which
i
> pass it's name via parameter.
> I generated it but it'll raise exception when a field has foreign key etc.
.
> I don't want to spend more time to this work. Do you have a script like
> this? Or program?
> If you have it could you share with me?
> Thanks.
>
>|||Thanks John, but i want to foreign keys add again after change data type.
This script just drop foreign keys.
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:55E6E65D-A653-4620-A2D3-C4BEB4A224AC@.microsoft.com...[vbcol=seagreen]
> Hi
> If you try and change a column's data type and the column is referenced by
> a
> foreign key, or is part of a primary key will give you an error. You will
> need to drop these before trying to change the columns datatype. The
> easiest
> way would be to script them, drop them and re-create them afterwards. To
> drop
> them see http://www.mssqlserver.com/scripts/drop_keys.sql
> John
> "Erencan SADIRODLU" wrote:
>|||Hi
But you could script them first, which is what I indicated in the response.
There are several ways to do this, as this is a one off job use Enterprise
Manager. If you take a backup before making any changes and restore the
database under a different name, you could use a tool such as Red Gate's SQL
Compare to check the differences (in fact you could use this to re-apply the
missing FKs and PKs).
John
"Erencan SADIRODLU" wrote:

> Thanks John, but i want to foreign keys add again after change data type.
> This script just drop foreign keys.
>
> "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> news:55E6E65D-A653-4620-A2D3-C4BEB4A224AC@.microsoft.com...
>
>

Script

I have a foreign key. I want to script how to create it without using
the management studio i.e. from the query analyser in SQL 2005. Is
there a system stored procedure or something that does this for you.
thanks for your help
NewishNo, you will have to build it like
exec ('alter table [' + @.table + '] drop constraint [' + @.constraint
+ ']')
from..
Read up this article
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/e960df1a-13fc-43ee-ba91-
34c1b719ac2c.htm
"Newish" <ahussain3@.gmail.com> wrote in message
news:1175352912.176014.48640@.q75g2000hsh.googlegroups.com...
>I have a foreign key. I want to script how to create it without using
> the management studio i.e. from the query analyser in SQL 2005. Is
> there a system stored procedure or something that does this for you.
> thanks for your help
> Newish
>|||Here's an example from BOL:
USE AdventureWorks ;
GO
CREATE TABLE Person.ContactBackup
(ContactID int) ;
GO
ALTER TABLE Person.ContactBackup
ADD CONSTRAINT FK_ContactBacup_Contact FOREIGN KEY (ContactID)
REFERENCES Person.Contact (ContactID) ;
ALTER TABLE Person.ContactBackup
DROP CONSTRAINT FK_ContactBacup_Contact ;
GO
DROP TABLE Person.ContactBackup ;
If you want to get the syntax 'for free' you can create the FK in EM and
rather than actually save the change, simply take a look at the script that
is generated. Cheers, Paul Ibison SQL Server MVP,
www.replicationanswers.com

script

Hello

I want to create sql script for my database. I know about “Generate SQL Server Scripts Wizard” but it just give me script for structure of my database and I want all records of my tables too.

And I’ve tried “Script table as / Insert to“via right click on my table too and it doesn’t give me a script to insert all records!

How can I create script to insert all records of a table to another table with same column properties?does exist any things to do it for me?

Thanks in advance.

Best to just create a database backup and create a TSQL script to restore it.

Or, you need to bulk copy the data out into a file and use bcp.exe or bulk insert to re-populate the table.

|||

Hi,

In order to generate insert statments for a table, you can use a very well written script that can be found at http://vyaskn.tripod.com/code.htm#inserts

Here you will find both the versions of the script (for SQL2000 and SQL2005) and its very easy to use.

Regards,
Neeraj

Script

Hi All,

When I run the script below I get the error "Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name '#table'".

CREATE TABLE #table (Check_Log VARCHAR(1000), Log_Time datetime default GetDate())

INSERT #table(Check_Log)
EXEC master..xp_cmdshell 'osql -S server -U user -P password -d db -Q"DBCC CHECKDB"'

EXEC master..xp_cmdshell 'bcp dbname.user.#table out Z:\Test\CheckDBRes.txt -S server -U user -P password'

SELECT * FROM #table

IF EXISTS (SELECT * FROM #table
WHERE Check_Log = 'CHECKDB found 0 allocation errors and 0 consistency errors in database')

PRINT 'No errors'

ELSE

RETURN

DROP TABLE #table

Can you please tell what I am doing wrong?

ThanksDidn't we do this laready?

All you had to do was curt and paste my origina;|||This is a little bit different. Your script doesn't put the results of checkdb into the text file. But this is one of the requirements.|||You will need to make this a permanent table

Also, make sure you put the batch column back in|||What is the purpose of the batch column?|||So that multiple processes can use trhe samme table, you can retain all of the logs, and then only ftp out 1 "batch" dbcc process at a time.

Trust me it will make life a lot easier

http://www.dbforums.com/showthread.php?t=1612711|||Thanks for your help.

Script

Hi All,
I need to write a script that would check the size of the db file and the size of transaction log file and it they are getting bigger than a certain amount I get notified. Any suggestions?
Thanks.start with sysfiles. the size number might not be totally accurate, you may want use sp_spaceused with the updateuseage argument first.|||Do you have a sample script?|||In fact I do have something somewhere that just goes and tallies the size of the database and log files. It does not however update usage because I was just looking for a quick and dirty number. This however will not meet your needs. I suggest you read up on sp_spaceused and take a look at the system catalog starting with sysfiles. This is an easy thing and it is all layed out for you in BOL if you know where to look.

In BOL, go to Contents\Transact SQL reference and than take a look at system stored procedure and system tables.|||Why wouldn't you just use alerts?|||We don't have a necessary software to do that. To get notified I use mailsend command.

Script

Hi all,
I need to put together a script that would let me know when the space is running low on each drive. Do you have a sample code? Thanks.Use xp_fixeddrives. The rest should be easy enough.|||I vote for WMI. Plenty of samples for you to choose from at this site. (http://www.microsoft.com/technet/scriptcenter/default.mspx).

xp_fixxeddrives may be easier, but you should also be monitoring your backup resources and other locations as well. Anyway, it's easy to learn and a usefull secondary skill to have.

Regards,

hmscott

Script

Hi Folks,
I need a script that it'll changed varchar field to nvarchar a table which i
pass it's name via parameter.
I generated it but it'll raise exception when a field has foreign key etc...
I don't want to spend more time to this work. Do you have a script like
this? Or program?
If you have it could you share with me?
Thanks.
Hi
If you try and change a column's data type and the column is referenced by a
foreign key, or is part of a primary key will give you an error. You will
need to drop these before trying to change the columns datatype. The easiest
way would be to script them, drop them and re-create them afterwards. To drop
them see http://www.mssqlserver.com/scripts/drop_keys.sql
John
"Erencan SADIRODLU" wrote:

> Hi Folks,
> I need a script that it'll changed varchar field to nvarchar a table which i
> pass it's name via parameter.
> I generated it but it'll raise exception when a field has foreign key etc...
> I don't want to spend more time to this work. Do you have a script like
> this? Or program?
> If you have it could you share with me?
> Thanks.
>
>
|||Thanks John, but i want to foreign keys add again after change data type.
This script just drop foreign keys.
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:55E6E65D-A653-4620-A2D3-C4BEB4A224AC@.microsoft.com...[vbcol=seagreen]
> Hi
> If you try and change a column's data type and the column is referenced by
> a
> foreign key, or is part of a primary key will give you an error. You will
> need to drop these before trying to change the columns datatype. The
> easiest
> way would be to script them, drop them and re-create them afterwards. To
> drop
> them see http://www.mssqlserver.com/scripts/drop_keys.sql
> John
> "Erencan SADIRODLU" wrote:
|||Hi
But you could script them first, which is what I indicated in the response.
There are several ways to do this, as this is a one off job use Enterprise
Manager. If you take a backup before making any changes and restore the
database under a different name, you could use a tool such as Red Gate's SQL
Compare to check the differences (in fact you could use this to re-apply the
missing FKs and PKs).
John
"Erencan SADIRODLU" wrote:

> Thanks John, but i want to foreign keys add again after change data type.
> This script just drop foreign keys.
>
> "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> news:55E6E65D-A653-4620-A2D3-C4BEB4A224AC@.microsoft.com...
>
>

Script

I have a foreign key. I want to script how to create it without using
the management studio i.e. from the query analyser in SQL 2005. Is
there a system stored procedure or something that does this for you.
thanks for your help
Newish
No, you will have to build it like
exec ('alter table [' + @.table + '] drop constraint [' + @.constraint + ']')
from..
Read up this article
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/e960df1a-13fc-43ee-ba91-34c1b719ac2c.htm
"Newish" <ahussain3@.gmail.com> wrote in message
news:1175352912.176014.48640@.q75g2000hsh.googlegro ups.com...
>I have a foreign key. I want to script how to create it without using
> the management studio i.e. from the query analyser in SQL 2005. Is
> there a system stored procedure or something that does this for you.
> thanks for your help
> Newish
>

Script

Hi Folks,
I need a script that it'll changed varchar field to nvarchar a table which i
pass it's name via parameter.
I generated it but it'll raise exception when a field has foreign key etc...
I don't want to spend more time to this work. Do you have a script like
this? Or program?
If you have it could you share with me?
Thanks.
Hi
If you try and change a column's data type and the column is referenced by a
foreign key, or is part of a primary key will give you an error. You will
need to drop these before trying to change the columns datatype. The easiest
way would be to script them, drop them and re-create them afterwards. To drop
them see http://www.mssqlserver.com/scripts/drop_keys.sql
John
"Erencan SADIRODLU" wrote:

> Hi Folks,
> I need a script that it'll changed varchar field to nvarchar a table which i
> pass it's name via parameter.
> I generated it but it'll raise exception when a field has foreign key etc...
> I don't want to spend more time to this work. Do you have a script like
> this? Or program?
> If you have it could you share with me?
> Thanks.
>
>
|||Thanks John, but i want to foreign keys add again after change data type.
This script just drop foreign keys.
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:55E6E65D-A653-4620-A2D3-C4BEB4A224AC@.microsoft.com...[vbcol=seagreen]
> Hi
> If you try and change a column's data type and the column is referenced by
> a
> foreign key, or is part of a primary key will give you an error. You will
> need to drop these before trying to change the columns datatype. The
> easiest
> way would be to script them, drop them and re-create them afterwards. To
> drop
> them see http://www.mssqlserver.com/scripts/drop_keys.sql
> John
> "Erencan SADIRODLU" wrote:
|||Hi
But you could script them first, which is what I indicated in the response.
There are several ways to do this, as this is a one off job use Enterprise
Manager. If you take a backup before making any changes and restore the
database under a different name, you could use a tool such as Red Gate's SQL
Compare to check the differences (in fact you could use this to re-apply the
missing FKs and PKs).
John
"Erencan SADIRODLU" wrote:

> Thanks John, but i want to foreign keys add again after change data type.
> This script just drop foreign keys.
>
> "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> news:55E6E65D-A653-4620-A2D3-C4BEB4A224AC@.microsoft.com...
>
>

SCRIPT

Hi
I am very familiar with insert statements, but how does a
value get passed for a user name and password from either
a web or windows application i.e
A simple insert statement would be
Insert into Table1
(username,password)values('bob','password')
but if you do not know the values of the username and
password are going to be then what would the query look
like.
So if I plan to make my password banana when I log onto
the application how would the script look like then,
would you leave the '' where banana would be as blank.
Insert into Table1
(username,password)values('bob','')
Thanks
Bob
BOB wrote:
> Hi
> I am very familiar with insert statements, but how does a
> value get passed for a user name and password from either
> a web or windows application i.e
> A simple insert statement would be
> Insert into Table1
> (username,password)values('bob','password')
> but if you do not know the values of the username and
> password are going to be then what would the query look
> like.
> So if I plan to make my password banana when I log onto
> the application how would the script look like then,
> would you leave the '' where banana would be as blank.
> Insert into Table1
> (username,password)values('bob','')
>
> Thanks
> Bob
First, we might enquire why you are storing user names and passwords in
a table. Can you rely on SQL Server's security mechanisms instead?
In general, though, is you have an attribute (column) in a table that
may contain unknown data, you allow NULL values. And you insert a NULL
or leave the column out of the insert operation altogether.
For web-based security, it's best to use Windows Authentication. Then no
passwords need to be sent at all. Some web servers may use hard-coded
connection strings to the server, but it's better to use Windows
Authentication.
Can you provide more detail about what you're trying to accomplish?
David Gugick
Imceda Software
www.imceda.com

scrip help

I wanna to have a script that will read a sertain table in a database. If a csrtain record that is being added exists in the table already I want it not to be added into teh specific tables. If it does not exist, i want it to be added.

Here is the logic that I wanna have:

READ OPCSHTO
GET CUST_CODE + LOC_CODE
IF EXIST CUST_CODE + LOC_CODE RECORD IN DPTORGANIZATIONSLOCATIONS
GO TO READ OPCSHTO

ELSE
DO ADD TO DPT.ORGANIZATIONLOCATIONS TABLE
DO ADD TO DPTORGANIZATIONSyou can have a stored procedure with CUST_CODE & LOC_CODE as input parameters. It will first check the table for this record by doing a count(*). If this count is zero it will insert the new record.|||Originally posted by rohitkumar
you can have a stored procedure with CUST_CODE & LOC_CODE as input parameters. It will first check the table for this record by doing a count(*). If this count is zero it will insert the new record.

That sounds cool. Can you be a little more specific cause I really don't know how I would do a sp.

thanks.|||I am bad at syntax and I have not tested this one, so you might have to spend some time on it to make it working

===================================
CREATE PROCEDURE USP_insert_dtporgloc AS
BEGIN
DECLARE @.CUST_CODE NCHAR(20)
DECLARE @.LOC_CODE NCHAR(20)

DECLARE cur_OPCSHTO SCROLL CURSOR FOR
SELECT
CUST_CODE , LOC_CODE
FROM
OPCSHTO

OPEN cur_OPCSHTO

FETCH NEXT FROM cur_OPCSHTO
INTO @.CUST_CODE, @.LOC_CODE

WHILE @.@.FETCH_STATUS = 0
BEGIN
IF (select count(*) from DPTORGANIZATIONSLOCATIONS where CUST_CODE = @.CUST_CODE and LOC_CODE = @.LOC_CODE) = 0
BEGIN
insert into DPTORGANIZATIONSLOCATIONS values (@.CUST_CODE, @.LOC_CODE, ...etc etc...)
END


FETCH NEXT FROM cur_OPCSHTO
INTO @.CUST_CODE, @.LOC_CODE
END
CLOSE cur_OPCSHTO
DEALLOCATE cur_OPCSHTO
Return
END
GO
======================================|||Originally posted by rohitkumar
I am bad at syntax and I have not tested this one, so you might have to spend some time on it to make it working

===================================
CREATE PROCEDURE USP_insert_dtporgloc AS
BEGIN
DECLARE @.CUST_CODE NCHAR(20)
DECLARE @.LOC_CODE NCHAR(20)

DECLARE cur_OPCSHTO SCROLL CURSOR FOR
SELECT
CUST_CODE , LOC_CODE
FROM
OPCSHTO

OPEN cur_OPCSHTO

FETCH NEXT FROM cur_OPCSHTO
INTO @.CUST_CODE, @.LOC_CODE

WHILE @.@.FETCH_STATUS = 0
BEGIN
IF (select count(*) from DPTORGANIZATIONSLOCATIONS where CUST_CODE = @.CUST_CODE and LOC_CODE = @.LOC_CODE) = 0
BEGIN
insert into DPTORGANIZATIONSLOCATIONS values (@.CUST_CODE, @.LOC_CODE, ...etc etc...)
END


FETCH NEXT FROM cur_OPCSHTO
INTO @.CUST_CODE, @.LOC_CODE
END
CLOSE cur_OPCSHTO
DEALLOCATE cur_OPCSHTO
Return
END
GO
======================================

Thanks a bunch...I will see how it turns out. How long have you been doing this for? Thanks for understanding......pretty new at this.|||Originally posted by rohitkumar
I am bad at syntax and I have not tested this one, so you might have to spend some time on it to make it working

===================================
CREATE PROCEDURE USP_insert_dtporgloc AS
BEGIN
DECLARE @.CUST_CODE NCHAR(20)
DECLARE @.LOC_CODE NCHAR(20)

DECLARE cur_OPCSHTO SCROLL CURSOR FOR
SELECT
CUST_CODE , LOC_CODE
FROM
OPCSHTO

OPEN cur_OPCSHTO

FETCH NEXT FROM cur_OPCSHTO
INTO @.CUST_CODE, @.LOC_CODE

WHILE @.@.FETCH_STATUS = 0
BEGIN
IF (select count(*) from DPTORGANIZATIONSLOCATIONS where CUST_CODE = @.CUST_CODE and LOC_CODE = @.LOC_CODE) = 0
BEGIN
insert into DPTORGANIZATIONSLOCATIONS values (@.CUST_CODE, @.LOC_CODE, ...etc etc...)
END


FETCH NEXT FROM cur_OPCSHTO
INTO @.CUST_CODE, @.LOC_CODE
END
CLOSE cur_OPCSHTO
DEALLOCATE cur_OPCSHTO
Return
END
GO
======================================

You think you would be able to right a descripting by each command, thatway I could understand what is going on and I can understand it better?
thanks for your help.|||I've tried writing a short description, let me know if something is missing

=========================================
CREATE PROCEDURE USP_insert_dtporgloc AS
BEGIN
/* variable declaration */
DECLARE @.CUST_CODE NCHAR(20)
DECLARE @.LOC_CODE NCHAR(20)

/* this will fetch CUST_CODE , LOC_CODE from cur_OPCSHTO and store it in an cursor "cur_OPCSHTO" (sort of an array) */
DECLARE cur_OPCSHTO SCROLL CURSOR FOR
SELECT
CUST_CODE , LOC_CODE
FROM
OPCSHTO

/* open this cursor for fetching the data */
OPEN cur_OPCSHTO

/* fetch first of the stored values and put them in these variables */
FETCH NEXT FROM cur_OPCSHTO
INTO @.CUST_CODE, @.LOC_CODE

/* repeat the process till last record in the cursor */
WHILE @.@.FETCH_STATUS = 0
BEGIN

/* count the number of recs in DPTORGANIZATIONSLOCATIONS having CUST_CODE , LOC_CODE. If this count is zero then insert this as a new record in the DPTORGANIZATIONSLOCATIONS table*/
IF (select count(*) from DPTORGANIZATIONSLOCATIONS where CUST_CODE = @.CUST_CODE and LOC_CODE = @.LOC_CODE) = 0
BEGIN
insert into DPTORGANIZATIONSLOCATIONS values (@.CUST_CODE, @.LOC_CODE, ...etc etc...)
END

/* fetch next of the stored values in the cursor and put them into variables*/
FETCH NEXT FROM cur_OPCSHTO
INTO @.CUST_CODE, @.LOC_CODE
END /* END corresponding to WHILE, the process between WHILE and END will repeat till there are no more records in the cursor*/

/* close the cursor and deallocate the resources*/
CLOSE cur_OPCSHTO
DEALLOCATE cur_OPCSHTO
Return
END
GO

SCREWY LAST BATCH DATE

Using SQL2k EE SP3
There's a spid in the activity monitor that has a Last Batch date of
1/1/1900 12:00AM however, the logged In date is recent. What could cause
this to happen?
tia
MG
MG,
Perhaps because it has logged in, but never executed a batch. 1/1/1900
12:00 AM is datetime 0, since last_batch is a non-nullable column.
I have seen this with some applications where 1 connnection will display
this behavior as other connections do the actual work.
RLF
"Hurme" <michael.geles@.thomson.com> wrote in message
news:5EEF3B0D-CA4D-43C8-84DB-88AA8614241A@.microsoft.com...
> Using SQL2k EE SP3
> There's a spid in the activity monitor that has a Last Batch date of
> 1/1/1900 12:00AM however, the logged In date is recent. What could cause
> this to happen?
> tia
> --
> MG

SCREWY LAST BATCH DATE

Using SQL2k EE SP3
There's a spid in the activity monitor that has a Last Batch date of
1/1/1900 12:00AM however, the logged In date is recent. What could cause
this to happen?
tia
--
MGMG,
Perhaps because it has logged in, but never executed a batch. 1/1/1900
12:00 AM is datetime 0, since last_batch is a non-nullable column.
I have seen this with some applications where 1 connnection will display
this behavior as other connections do the actual work.
RLF
"Hurme" <michael.geles@.thomson.com> wrote in message
news:5EEF3B0D-CA4D-43C8-84DB-88AA8614241A@.microsoft.com...
> Using SQL2k EE SP3
> There's a spid in the activity monitor that has a Last Batch date of
> 1/1/1900 12:00AM however, the logged In date is recent. What could cause
> this to happen?
> tia
> --
> MG

screenshots showing solution

After setting up
SQL2005express server with
mixed authentification I got the problem
1. I couldnt find a working ConnectionString
2. Studio2005 didnt connect to SQL any more
In the meantime I found that at least the following OLEDB-ConnectionString is working, when Im logged in as admin and can use Windows Autentication:
Provider='sqloledb'
Data Source='.' - without '/SQLEXPRESS' !!
Initial Catalog='MyDatabaseName'
Integrated Security='SSPI'
For details of SQL setup and code to test possible connetion strings
please see my homepage.
Martin
text of my question from 02 Dec 2005
I want to feed data of a C++ 6.0 project into SQL server and hoped that StudioExpress would give me the correct connection string in detail.
But my StudioExpress doesnt conntect to a SQL server configured for SQL-Authentication.
I made screenshote of the details an put them in subfolders of my homepage
http://home.arcor.SQL2005.
Does anybody know what exact connection string has to be used and which changes in StudioExpress AdvancedConnectionProperties are necessary to establish a working connection?

The above link contains a collection of screenshots with details of the problem.
In the meantime I did a standard setup of the whole StudioExpress2005 C# paket and put screenshots on my homepage where you can see the difference between standard setup and single SQLExpress setup in SQL-Authentication mode.
Martin

Screen output vs. print output, SSRS 2000

Hi,
I'm building a report for a client (in SSRS 2000), where I am
experiencing the fact that the output on the screen (ie, what is
rendered by Report Manager) is very different from the print output (or
export output, for that matter).
I am using a list, with a couple of tables (with fixed size) embedded
in it. While shown on screen, the page breaks are (as far as I can
tell) randomly inserted, no matter what I set as properties for Page
Break, Keep Together, etc. The output while exporting to (for example)
PDF is great, and exactly as I want it.
Has anyone experienced a similar problem? If so, have you solved it,
and how?
Thanks,
Jeroen Buisman
InfoReports Business Intelligence B.V.I have read in training material that the output to the screen (HTML) does
not have fixed page bounderies but goes until it hits the end of a group set
for a page break at the end of the group. HTML is not a "page oriented"
output format, while PDF is. This has been my experience.
<jeroen.buisman@.gmail.com> wrote in message
news:1141808034.990107.276690@.i39g2000cwa.googlegroups.com...
> Hi,
> I'm building a report for a client (in SSRS 2000), where I am
> experiencing the fact that the output on the screen (ie, what is
> rendered by Report Manager) is very different from the print output (or
> export output, for that matter).
> I am using a list, with a couple of tables (with fixed size) embedded
> in it. While shown on screen, the page breaks are (as far as I can
> tell) randomly inserted, no matter what I set as properties for Page
> Break, Keep Together, etc. The output while exporting to (for example)
> PDF is great, and exactly as I want it.
> Has anyone experienced a similar problem? If so, have you solved it,
> and how?
> Thanks,
> Jeroen Buisman
> InfoReports Business Intelligence B.V.
>|||Hi,
if you dont mention the margin propert for the report layout then this
problem will come up for the HTML print and not for PDF. so you have to
mention the margin hight,width,top,left in the rdl for the html activex
control to get that property otherwise it will get the default property which
makes the report ugly. You can fix temp by changing the margin property to
low in HTML print active control while viewing.
Bava
"jeroen.buisman@.gmail.com" wrote:
> Hi,
> I'm building a report for a client (in SSRS 2000), where I am
> experiencing the fact that the output on the screen (ie, what is
> rendered by Report Manager) is very different from the print output (or
> export output, for that matter).
> I am using a list, with a couple of tables (with fixed size) embedded
> in it. While shown on screen, the page breaks are (as far as I can
> tell) randomly inserted, no matter what I set as properties for Page
> Break, Keep Together, etc. The output while exporting to (for example)
> PDF is great, and exactly as I want it.
> Has anyone experienced a similar problem? If so, have you solved it,
> and how?
> Thanks,
> Jeroen Buisman
> InfoReports Business Intelligence B.V.
>|||Bava
can you explain this more in detail
Thx|||True, but the page breaks are occurring erraticaly. If it were so that
the HTML page break would only occur after the first group which has
the "Page Break at End" (or something like that) set, the break would
occur on exactly the same spot, right? So my guess is that that's not
the case. Will check it though, when I visit my client again tomorrow.
Thx,
Jeroen|||Hi Bava,
You mean that for the Report object, I should set explicit margins? If
so, that's something I always do with my reports. If that's not wat you
mean: could you please clarify what you mean with "changing the margin
property to low in HTML print active control"?
Thx,
Jeroen|||Hi,
The report rdl has the element like
<Report>
<RightMargin>0.2in</RightMargin>
<LeftMargin>0.2in</LeftMargin>
<TopMargin>0.2in</TopMargin>
</Report>
you have to set explicit for the report otherwise it will take the default
of .5in i think.
The default of 0.5in will not be good for some reports in HTML print control
that is avilable in report manager near the Export link.
You can see the value of the report margin set during the print control
preview mode. You can adjust the margin in this print control preview mode
but it will not be saved to the report or in the setting.
Bava
"Jeroen Buisman" wrote:
> Hi Bava,
> You mean that for the Report object, I should set explicit margins? If
> so, that's something I always do with my reports. If that's not wat you
> mean: could you please clarify what you mean with "changing the margin
> property to low in HTML print active control"?
> Thx,
> Jeroen
>|||Ow ok... however, the problem I'm having is not with printing, in fact,
printing is what goes well. The rendering on screen doesn't work as it
should.

scratch that

I am getting the error

Error: 18456, Severity: 14, State: 16.
Login failed for user 'PRI\sqlservice'. [CLIENT: 172.16.9.2]

in the log repeated every 15 seconds or so. I am logged into the server as pri\sqlservice, I have started the sql server and sql server agent with pri\sqlservice and I can access databases and tables inside the Server Management studio. I have set up the login pri\sqlservice and given it dbo owner access to all databases.

I am in the process of upgrading from 2000 to 2005. I have installed a new sql server 2005, restored backups of databases from 2000. I have also converted all packages and uploaded those to the new server (although they all point to the 2000 server). I have imported the jobs, but all but one are disabled and the one that is enabled ran okay when I ran it manually.

I have researched and researched this issue, and none seem to apply to my specific issue.

This is an extract of my errorlog:

2006-12-20 16:23:16.95 Server Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)
Oct 14 2005 00:33:37
Copyright (c) 1988-2005 Microsoft Corporation
Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 1)

2006-12-20 16:23:16.98 Server (c) 2005 Microsoft Corporation.
2006-12-20 16:23:16.98 Server All rights reserved.
2006-12-20 16:23:16.98 Server Server process ID is 1780.
2006-12-20 16:23:16.98 Server Logging SQL Server messages in file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'.
2006-12-20 16:23:16.98 Server This instance of SQL Server last reported using a process ID of 4532 at 12/20/2006 4:23:52 PM (local) 12/20/2006 9:23:52 PM (UTC). This is an informational message only; no user action is required.
2006-12-20 16:23:16.98 Server Registry startup parameters:
2006-12-20 16:23:17.00 Server -d C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\master.mdf
2006-12-20 16:23:17.00 Server -e C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG
2006-12-20 16:23:17.00 Server -l C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\mastlog.ldf
2006-12-20 16:23:17.23 Server SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2006-12-20 16:23:17.23 Server Detected 2 CPUs. This is an informational message; no user action is required.
2006-12-20 16:23:17.93 Server Set AWE Enabled to 1 in the configuration parameters to allow use of more memory.
2006-12-20 16:23:19.65 Server Using dynamic lock allocation. Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node. This is an informational message only. No user action is required.
2006-12-20 16:23:22.07 Server Attempting to initialize Microsoft Distributed Transaction Coordinator (MS DTC). This is an informational message only. No user action is required.
2006-12-20 16:23:23.21 Server Attempting to recover in-doubt distributed transactions involving Microsoft Distributed Transaction Coordinator (MS DTC). This is an informational message only. No user action is required.
2006-12-20 16:23:23.48 Server Database Mirroring Transport is disabled in the endpoint configuration.
2006-12-20 16:23:23.79 spid5s Starting up database 'master'.
2006-12-20 16:23:25.01 spid5s Recovery is writing a checkpoint in database 'master' (1). This is an informational message only. No user action is required.
2006-12-20 16:23:26.17 spid5s SQL Trace ID 1 was started by login "sa".
2006-12-20 16:23:26.37 spid5s Starting up database 'mssqlsystemresource'.
2006-12-20 16:23:27.93 spid9s Starting up database 'model'.
2006-12-20 16:23:27.95 spid5s Server name is 'KSDBT01'. This is an informational message only. No user action is required.
2006-12-20 16:23:29.06 spid9s Clearing tempdb database.
2006-12-20 16:23:29.54 Server A self-generated certificate was successfully loaded for encryption.
2006-12-20 16:23:29.62 Server Server is listening on [ 'any' <ipv4> 1433].
2006-12-20 16:23:29.62 Server Server local connection provider is ready to accept connection on [ \\.\pipe\SQLLocal\MSSQLSERVER ].
2006-12-20 16:23:29.62 Server Server local connection provider is ready to accept connection on [ \\.\pipe\sql\query ].
2006-12-20 16:23:29.64 Server Server is listening on [ 127.0.0.1 <ipv4> 1434].
2006-12-20 16:23:29.64 Server Dedicated admin connection support was established for listening locally on port 1434.
2006-12-20 16:23:29.68 Server SQL Server is now ready for client connections. This is an informational message; no user action is required.
2006-12-20 16:23:32.56 spid9s Starting up database 'tempdb'.
2006-12-20 16:23:32.67 spid13s Starting up database 'msdb'.
2006-12-20 16:23:32.67 spid12s Starting up database 'test'.
2006-12-20 16:23:32.67 spid14s Starting up database 'bravoAztecnology'.
2006-12-20 16:23:32.67 spid15s Starting up database 'bravoKNE'.
2006-12-20 16:23:32.67 spid16s Starting up database 'bravoKNS'.
2006-12-20 16:23:32.67 spid17s Starting up database 'bravoKNSBelgium'.
2006-12-20 16:23:32.68 spid18s Starting up database 'bravoKNSCanada'.
2006-12-20 16:23:32.68 spid19s Starting up database 'bravoKNSEngland'.
2006-12-20 16:23:34.79 spid20s The Service Broker protocol transport is disabled or not configured.
2006-12-20 16:23:34.81 spid20s The Database Mirroring protocol transport is disabled or not configured.
2006-12-20 16:23:35.01 spid12s Starting up database 'bravoKNSKennedy'.
2006-12-20 16:23:35.20 spid17s Starting up database 'bravoKNSSuperior'.
2006-12-20 16:23:35.35 spid13s Starting up database 'bravoKNSSuperiorSS'.
2006-12-20 16:23:35.48 spid19s Starting up database 'stamp'.
2006-12-20 16:23:35.83 spid20s Service Broker manager has started.
2006-12-20 16:23:38.59 spid14s Starting up database 'KNSSpecial'.
2006-12-20 16:23:39.31 spid18s Starting up database 'knsRPCS'.
2006-12-20 16:23:39.39 spid14s Analysis of database 'KNSSpecial' (16) is 100% complete (approximately 0 seconds remain). This is an informational message only. No user action is required.
2006-12-20 16:23:43.03 spid5s Recovery of any in-doubt distributed transactions involving Microsoft Distributed Transaction Coordinator (MS DTC) has completed. This is an informational message only. No user action is required.
2006-12-20 16:23:43.03 spid5s Recovery is complete. This is an informational message only. No user action is required.
2006-12-20 16:23:50.95 spid51 Using 'xpsqlbot.dll' version '2005.90.1399' to execute extended stored procedure 'xp_qv'. This is an informational message only; no user action is required.
2006-12-20 16:23:55.85 spid51 Using 'xpstar90.dll' version '2005.90.1399' to execute extended stored procedure 'xp_instance_regread'. This is an informational message only; no user action is required.
2006-12-20 16:23:57.10 spid51 Using 'xplog70.dll' version '2005.90.1399' to execute extended stored procedure 'xp_msver'. This is an informational message only; no user action is required.
2006-12-20 16:24:00.02 Logon Error: 18456, Severity: 14, State: 16.
2006-12-20 16:24:00.02 Logon Login failed for user 'PRI\sqlservice'. [CLIENT: 172.16.9.2]
2006-12-20 16:24:00.06 Logon Error: 18456, Severity: 14, State: 16.
2006-12-20 16:24:00.06 Logon Login failed for user 'PRI\sqlservice'. [CLIENT: 172.16.9.2]
2006-12-20 16:24:01.06 Logon Error: 18456, Severity: 14, State: 16.
2006-12-20 16:24:01.06 Logon Login failed for user 'PRI\sqlservice'. [CLIENT: 172.16.9.2]
2006-12-20 16:24:01.07 Logon Error: 18456, Severity: 14, State: 16.
2006-12-20 16:24:01.07 Logon Login failed for user 'PRI\sqlservice'. [CLIENT: 172.16.9.2]
2006-12-20 16:24:03.84 Logon Error: 18456, Severity: 14, State: 16.
2006-12-20 16:24:03.84 Logon Login failed for user 'PRI\sqlservice'. [CLIENT: 172.16.9.2]
2006-12-20 16:24:03.85 Logon Error: 18456, Severity: 14, State: 16.
2006-12-20 16:24:03.85 Logon Login failed for user 'PRI\sqlservice'. [CLIENT: 172.16.9.2]
2006-12-20 16:24:03.96 Logon Error: 18456, Severity: 14, State: 16.
2006-12-20 16:24:03.96 Logon Login failed for user 'PRI\sqlservice'. [CLIENT: 172.16.9.2]
2006-12-20 16:24:03.98 Logon Error: 18456, Severity: 14, State: 16.
2006-12-20 16:24:03.98 Logon Login failed for user 'PRI\sqlservice'. [CLIENT: 172.16.9.2]
2006-12-20 16:24:41.41 Logon Error: 18456, Severity: 14, State: 16.
2006-12-20 16:24:41.41 Logon Login failed for user 'PRI\sqlservice'. [CLIENT: 172.16.9.2]
2006-12-20 16:24:41.41 Logon Error: 18456, Severity: 14, State: 16.
2006-12-20 16:24:41.41 Logon Login failed for user 'PRI\sqlservice'. [CLIENT: 172.16.9.2]

Just found out its someone running a script to get into our server.|||That wasn't it. The same server is the one trying to log in. I have database mail turned on, too.

Scrash OS, Win 2000 server while restoring SQL server database

Hi All,
I have a problem with restoring SQL server database:
OS: Window 2000 server
Database: SQL server 2000, SP3a
Hardware Configuration:
1 CPU P4 3GHz
HDD: 120GB (C:60GB, D:140GB)
Backup file size: 30GB
I want to restore it on D driver.
Restoring process went over 60% then an popup dialog show up that "Operating
system is shutting down" and count down time in 60 seconds.
After reboot, an error : "NTLDR is missing. Press any key to continue"
Windows can't boot.
Please tell me what problem I had and how to solve it.
Thanks in advanced
TN
Remove the floppy disk from the floppy drive.
Remove any CD from a CD/DVD drive.
Try and reboot. If that doesn't work, use your recovery disk.
Geoff N. Hiten
Microsoft SQL Server MVP
"TN" <TN@.discussions.microsoft.com> wrote in message
news:416A7A3D-F9A6-4E29-991B-DC035D085C65@.microsoft.com...
> Hi All,
> I have a problem with restoring SQL server database:
> OS: Window 2000 server
> Database: SQL server 2000, SP3a
> Hardware Configuration:
> 1 CPU P4 3GHz
> HDD: 120GB (C:60GB, D:140GB)
> Backup file size: 30GB
> I want to restore it on D driver.
> Restoring process went over 60% then an popup dialog show up that
> "Operating
> system is shutting down" and count down time in 60 seconds.
> After reboot, an error : "NTLDR is missing. Press any key to continue"
> Windows can't boot.
> Please tell me what problem I had and how to solve it.
> Thanks in advanced
> TN

Scrash OS, Win 2000 server while restoring SQL server database

Hi All,
I have a problem with restoring SQL server database:
OS: Window 2000 server
Database: SQL server 2000, SP3a
Hardware Configuration:
1 CPU P4 3GHz
HDD: 120GB (C:60GB, D:140GB)
Backup file size: 30GB
I want to restore it on D driver.
Restoring process went over 60% then an popup dialog show up that "Operating
system is shutting down" and count down time in 60 seconds.
After reboot, an error : "NTLDR is missing. Press any key to continue"
Windows can't boot.
Please tell me what problem I had and how to solve it.
Thanks in advanced
TNRemove the floppy disk from the floppy drive.
Remove any CD from a CD/DVD drive.
Try and reboot. If that doesn't work, use your recovery disk.
Geoff N. Hiten
Microsoft SQL Server MVP
"TN" <TN@.discussions.microsoft.com> wrote in message
news:416A7A3D-F9A6-4E29-991B-DC035D085C65@.microsoft.com...
> Hi All,
> I have a problem with restoring SQL server database:
> OS: Window 2000 server
> Database: SQL server 2000, SP3a
> hardware Configuration:
> 1 CPU P4 3GHz
> HDD: 120GB (C:60GB, D:140GB)
> Backup file size: 30GB
> I want to restore it on D driver.
> Restoring process went over 60% then an popup dialog show up that
> "Operating
> system is shutting down" and count down time in 60 seconds.
> After reboot, an error : "NTLDR is missing. Press any key to continue"
> Windows can't boot.
> Please tell me what problem I had and how to solve it.
> Thanks in advanced
> TN

Scrash OS, Win 2000 server while restoring SQL server database

Hi All,
I have a problem with restoring SQL server database:
OS: Window 2000 server
Database: SQL server 2000, SP3a
Hardware Configuration:
1 CPU P4 3GHz
HDD: 120GB (C:60GB, D:140GB)
Backup file size: 30GB
I want to restore it on D driver.
Restoring process went over 60% then an popup dialog show up that "Operating
system is shutting down" and count down time in 60 seconds.
After reboot, an error : "NTLDR is missing. Press any key to continue"
Windows can't boot.
Please tell me what problem I had and how to solve it.
Thanks in advanced
TNRemove the floppy disk from the floppy drive.
Remove any CD from a CD/DVD drive.
Try and reboot. If that doesn't work, use your recovery disk.
Geoff N. Hiten
Microsoft SQL Server MVP
"TN" <TN@.discussions.microsoft.com> wrote in message
news:416A7A3D-F9A6-4E29-991B-DC035D085C65@.microsoft.com...
> Hi All,
> I have a problem with restoring SQL server database:
> OS: Window 2000 server
> Database: SQL server 2000, SP3a
> Hardware Configuration:
> 1 CPU P4 3GHz
> HDD: 120GB (C:60GB, D:140GB)
> Backup file size: 30GB
> I want to restore it on D driver.
> Restoring process went over 60% then an popup dialog show up that
> "Operating
> system is shutting down" and count down time in 60 seconds.
> After reboot, an error : "NTLDR is missing. Press any key to continue"
> Windows can't boot.
> Please tell me what problem I had and how to solve it.
> Thanks in advanced
> TN

Scrambling sensitive data

Hello, I am looking for a script in (SQL Server platform) that can scramble customer details and employee details.

I have a list of employees that deal with a segment of customers, and I want to be able to scramble the data for a particular employee using perhaps the employee's ID or a script that can scramble the whole database. For this database I have over 200000 customer names and a few thousand employees.

I have tried to scramble the data using some form of substring, but the data is still recognisable.

Can someone help me please! Thanx.microsoft DPAPI?

Scrambling Data in a table

We have a bunch of data that includes things like DNS names and host names. For testing purposes, we want to give people access to our data but we do not want them to see the real names of the items I mentioned prior. What I would like to do is a letter replacement for each character in the name, thus A could become T, B could become U, etc. It's not a big deal if the end user can unscrable these, they probably won't anyways and it's not a big deal if they do, our client just wants something to make it not so obvious.

Is this possible to do through a SQL query and if so, can you give my pointers on how to accomplish this?

Otherwise I will probably use a VB solution, but it would be similar if I could just write a SQL query that I could send to anyone that needs to do this.

you can use SQL to replace things in select statements

read this :http://www.java2s.com/Code/SQL/Function/CallREPLACEfunctioninselectclause.htm

hth,
mcm

|||

U can use Replace function

Thank u

Baba

Please remember to click "Mark as Answer" on this post if it helped you.

|||

You can create an SP which applies some encoding logic over the supplied value and one SP which does exactly the reverse of it. The encoding and decoding logic can absolutely be your ( which ever way you like it to be ). Generally you can play with the ascii value of the character. One caution that should be exercised is that your encode and decode logic must be strong and tested enough for you can't bare wrong values when encoding or decoding.

Hope this will help.

|||

I see how I can use replace to replace one letter, but how would I go about replacing all the letters? Some of my tables have thousands of records, if I have to run a select and then update query for every letter, it's going to take a LONG time.

|||

Hi,

but how would I go about replacing all the letters? Some of my tables have thousands of records, if I have to run a select and then update query for every letter, it's going to take a LONG time.

It seems that you have misunderstood the community members' suggestions. What you want to do is just to hide the real information since you don't want the information to be seen by the users. So we replacing all the records in database would not be a good practice, and actually it's not necessary. As mentioned by others, you have two ways to achieve that.

First, write the "replace" logic in your application level, not in the database level. When you have retrieve a real data from the database, you should replace the specific value against the data before displaying.

Another way is, you can create a stored procedure, after you have select the result set, just use SELECT REPLACE (Ep1,Ep2,Ep3) to replace the char in the result.

As for the speed, the replace operation against a variable would not take much time.

Thanks.

|||

I could do this in the application level, but i've been asked to do it in the database, so that's what I'm trying to do.

And I want to replace the data in the database... I see how the replace function works to replace one character at a time, but when you run your select query, you seem to only have the option to replace one letter at a time. I need to replace 26 letters and 10 numbers, which is what I'm not sure how to do.

SELECT REPLACE(name, "a", "x")

That would replace one character... I have to do it 35 more times for all the different letters and numbers, and then I have to acctually update the database with the new values. And then I have to do it on multiple fields too.

|||

UPDATE YourTable

SET YourField=REPLACE(REPLACE(REPLACE(YourField,"a","x"),"b","y"),"c","z")

Of course, that'll get really nasty with 36 of them, and you will run into problems because if you first replace a with x, when you get to replacing x with whatever, now you are replacing the old x and the new x with something. I would suggest writing a user defined function (UDF) to do the conversion for you. Then you can just:

UPDATE YourTable

SET YourField=dbo.Scramble(YourField)

|||

Kriswd40:

It's not a big deal if the end user can unscrable these, they probably won't anyways and it's not a big deal if they do, our client just wants something to make it not so obvious.

With due respect to your client, that makes no sense at all. Either you hide the information or you don't. Making it "not obvious" is ridiculous. And what's the point of making it available in develpment if they can't read it, anyway?

|||

It's not all fields that I'm changing, just IP Addresses, DNS entries, serial numbers, ect so the data is still very usable. It's not live data, periodically we are given a backup of the data we can use for developement but the client no longer wants us to have access to some of the sensative information in this data. The best thing to do would be to completely encrypt/randomize these fields so they cannot be recovered, but at this time we do nothing so at least this is a step in the right direction.

Scrambled data in some fields

We have recently discovered that several sending systems (all using the same subroutine) have been scrambling some of the data sent to an MS SQL database.

I'm trying to figure out how to identify the scrambled records.

We know that records with zero in the 4th, 6th and 7th positions of their SSNs, had the SSN rearranged. Instead of the SSN in order (123456789) it is now (467512389).

The SSN is used as a subsidiary ID field in the system (let's call it the SID field.) Since some people don't have SSNs, an alternate number, which may begin with three zeros, is used.

I can select off all SIDs beginning with 3 zeros, but some of those will be legitimate records.

I can also select off all SIDs with zeroes in positions 4, 7 and 8, but only SOME systems were making the mistaking.

I can't figure out how to make a list of SIDs with 4, 7, and 8 for which a corresponding SID with 3 zeroes in front exists. This list would be the first we examine. (We will have to check all '000' SIDs, since it's possible that only 'bad' SIDs were created for some people, instead of both 'good' and 'bad' SIDs.)

Can someone help a novice SQL programmer with this (to me) perplexing problem?If I understand you, you need to try the following

INSERT INTO PossibleErrors
( SID )
SELECT SID
FROM Table
WHERE SUBSTRING(convert(varchar,SID),1,3) = '000'
AND SUBSTRING(convert(varchar,SID),4,1) = '0'
AND SUBSTRING(convert(varchar,SID),7,1) = '0'
AND SUBSTRING(convert(varchar,SID),8,1) = '0'

scramble ssn with sql server

Hi,
I'm trying to scramble the ssn#s within our database. I would need a 9
digit number to be converted into another 9 digit number in our dev
database.
Example #1:
ssn: 123456789 converts to 987654321
Also there is a catch, there is a possibility that there could be
duplicate ssn within a table due to bad data. I was the 2 records with
the same actual ssn# to be converted into the same scrambled ssn# using
sql server (so that the scrambled ssn#s match) for this issue.
Is there a way to do this?
Thanks
:D
I hope you are not thinking about reversing the SSN in order to protect the
data? Any third grader could figure that out and would know all the SSNs.
Your best bet would be to replace them with actual random IDs. You might
try this approach...
Assuming you have SSN stored in one table, lets call it CUSTOMERS...
create a new table SSN_MASK. Insert into this table every unique SSN, along
with an identity column to give them a unique value. Then use the values in
this table to update SSN in the real table. Lastly, drop the SSN_MAsk table
(or at least truncate it) so no one can match the bogus SSNs to the real
thing.
create table SSN_MASK
(
NEW_SSN integer identity primary key not null,
OLD_SSN varchar(9) -- not sure how you defined it
);
insert into SSN_MASK (OLD_SSN) (select unique SSN from CUSTOMERS);
update CUSTOMERS
set SSN = (select
right('000000000' + cast(a.NEW_SSN as varchar(9)),9)
-- make sure the new SSN is 9 characters
from SSN_MASK as a
where a.OLD_SSN = CUSTOMERS.SSN);
drop table SSN_MASK;
<dmalhotr2001@.yahoo.com> wrote in message
news:1158351116.321489.122450@.i3g2000cwc.googlegro ups.com...
> Hi,
> I'm trying to scramble the ssn#s within our database. I would need a 9
> digit number to be converted into another 9 digit number in our dev
> database.
> Example #1:
> ssn: 123456789 converts to 987654321
>
> Also there is a catch, there is a possibility that there could be
> duplicate ssn within a table due to bad data. I was the 2 records with
> the same actual ssn# to be converted into the same scrambled ssn# using
> sql server (so that the scrambled ssn#s match) for this issue.
> Is there a way to do this?
> Thanks
> :D
>

scramble ssn with sql server

Hi,
I'm trying to scramble the ssn#s within our database. I would need a 9
digit number to be converted into another 9 digit number in our dev
database.
Example #1:
ssn: 123456789 converts to 987654321
Also there is a catch, there is a possibility that there could be
duplicate ssn within a table due to bad data. I was the 2 records with
the same actual ssn# to be converted into the same scrambled ssn# using
sql server (so that the scrambled ssn#s match) for this issue.
Is there a way to do this?
Thanks
:D
Hi
If you wish to make the data anonymous then you will need an algorithm that
is not easily breakable. Normal encryption procedures would not necessarily
give you the format you want, but just moving numbers or replacement may not
give you the require level of obfuscation.
To change multiple values of a given column you can add an extra column say
hasbeenchange which you set then the data has been changed. You can then
cursor through the records in the table and change each value that does not
already have hasbeenchange set
DECLARE @.ssn char(9)
DECLARE ssn_cursor CURSOR FOR
SELECT ssn
FROM Mytable WHERE hasbeenchange = 0
ORDER BY SSN
OPEN ssn_cursor
FETCH NEXT FROM ssn_cursor INTO @.ssn
WHILE @.@.FETCH_STATUS = 0
BEGIN
UPDATE mytable
SET ssn = fn_jiggerypokery(ssn)
WHERE ssn = @.ssn
AND hasbeenchange = 0
FETCH NEXT FROM ssn_cursor INTO @.ssn
END
CLOSE ssn_cursor
DEALLOCATE ssn_cursor
John
"dmalhotr2001@.yahoo.com" wrote:

> Hi,
> I'm trying to scramble the ssn#s within our database. I would need a 9
> digit number to be converted into another 9 digit number in our dev
> database.
> Example #1:
> ssn: 123456789 converts to 987654321
>
> Also there is a catch, there is a possibility that there could be
> duplicate ssn within a table due to bad data. I was the 2 records with
> the same actual ssn# to be converted into the same scrambled ssn# using
> sql server (so that the scrambled ssn#s match) for this issue.
> Is there a way to do this?
> Thanks
> :D
>
|||dmalhotr2001@.yahoo.com wrote:
> Hi,
> I'm trying to scramble the ssn#s within our database. I would need a 9
> digit number to be converted into another 9 digit number in our dev
> database.
> Example #1:
> ssn: 123456789 converts to 987654321
>
> Also there is a catch, there is a possibility that there could be
> duplicate ssn within a table due to bad data. I was the 2 records with
> the same actual ssn# to be converted into the same scrambled ssn# using
> sql server (so that the scrambled ssn#s match) for this issue.
> Is there a way to do this?
> Thanks
> :D
For what purpose do you want to do this? One reason might be that you
want to generate some test data without compromising any confidential
information. In that case you could use the CHECKSUM or RAND functions
to generate some arbitrary values.
Another reason might be that you want to secure the data. "Scrambling"
a number has nothing to do with any meaningful kind of security so here
are some other suggestions instead. You can encrypt the data and/or to
limit access to column/rows using the SQL Server security model.
Probably you'll want to use a combination of both.
SQL Server 2005 has encryption functions built-in, so take a look at
the encryption topics in Books Online. In earlier versions you can use
third party software to achieve the same thing.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
|||John,
Can I get a copy of dbo.fn_jiggerypokery()?
With a name like that, it 'sounds' interesting...
;-)
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:E64B9234-AACC-4453-998E-21ACCFA81699@.microsoft.com...[vbcol=seagreen]
> Hi
> If you wish to make the data anonymous then you will need an algorithm
> that
> is not easily breakable. Normal encryption procedures would not
> necessarily
> give you the format you want, but just moving numbers or replacement may
> not
> give you the require level of obfuscation.
> To change multiple values of a given column you can add an extra column
> say
> hasbeenchange which you set then the data has been changed. You can then
> cursor through the records in the table and change each value that does
> not
> already have hasbeenchange set
> DECLARE @.ssn char(9)
> DECLARE ssn_cursor CURSOR FOR
> SELECT ssn
> FROM Mytable WHERE hasbeenchange = 0
> ORDER BY SSN
> OPEN ssn_cursor
> FETCH NEXT FROM ssn_cursor INTO @.ssn
> WHILE @.@.FETCH_STATUS = 0
> BEGIN
> UPDATE mytable
> SET ssn = fn_jiggerypokery(ssn)
> WHERE ssn = @.ssn
> AND hasbeenchange = 0
> FETCH NEXT FROM ssn_cursor INTO @.ssn
> END
> CLOSE ssn_cursor
> DEALLOCATE ssn_cursor
> John
> "dmalhotr2001@.yahoo.com" wrote:

scramble ssn with sql server

Hi,
I'm trying to scramble the ssn#s within our database. I would need a 9
digit number to be converted into another 9 digit number in our dev
database.
Example #1:
ssn: 123456789 converts to 987654321
Also there is a catch, there is a possibility that there could be
duplicate ssn within a table due to bad data. I was the 2 records with
the same actual ssn# to be converted into the same scrambled ssn# using
sql server (so that the scrambled ssn#s match) for this issue.
Is there a way to do this?
Thanks
:DHi
If you wish to make the data anonymous then you will need an algorithm that
is not easily breakable. Normal encryption procedures would not necessarily
give you the format you want, but just moving numbers or replacement may not
give you the require level of obfuscation.
To change multiple values of a given column you can add an extra column say
hasbeenchange which you set then the data has been changed. You can then
cursor through the records in the table and change each value that does not
already have hasbeenchange set
DECLARE @.ssn char(9)
DECLARE ssn_cursor CURSOR FOR
SELECT ssn
FROM Mytable WHERE hasbeenchange = 0
ORDER BY SSN
OPEN ssn_cursor
FETCH NEXT FROM ssn_cursor INTO @.ssn
WHILE @.@.FETCH_STATUS = 0
BEGIN
UPDATE mytable
SET ssn = fn_jiggerypokery(ssn)
WHERE ssn = @.ssn
AND hasbeenchange = 0
FETCH NEXT FROM ssn_cursor INTO @.ssn
END
CLOSE ssn_cursor
DEALLOCATE ssn_cursor
John
"dmalhotr2001@.yahoo.com" wrote:

> Hi,
> I'm trying to scramble the ssn#s within our database. I would need a 9
> digit number to be converted into another 9 digit number in our dev
> database.
> Example #1:
> ssn: 123456789 converts to 987654321
>
> Also there is a catch, there is a possibility that there could be
> duplicate ssn within a table due to bad data. I was the 2 records with
> the same actual ssn# to be converted into the same scrambled ssn# using
> sql server (so that the scrambled ssn#s match) for this issue.
> Is there a way to do this?
> Thanks
> :D
>|||dmalhotr2001@.yahoo.com wrote:
> Hi,
> I'm trying to scramble the ssn#s within our database. I would need a 9
> digit number to be converted into another 9 digit number in our dev
> database.
> Example #1:
> ssn: 123456789 converts to 987654321
>
> Also there is a catch, there is a possibility that there could be
> duplicate ssn within a table due to bad data. I was the 2 records with
> the same actual ssn# to be converted into the same scrambled ssn# using
> sql server (so that the scrambled ssn#s match) for this issue.
> Is there a way to do this?
> Thanks
> :D
For what purpose do you want to do this? One reason might be that you
want to generate some test data without compromising any confidential
information. In that case you could use the CHECKSUM or RAND functions
to generate some arbitrary values.
Another reason might be that you want to secure the data. "Scrambling"
a number has nothing to do with any meaningful kind of security so here
are some other suggestions instead. You can encrypt the data and/or to
limit access to column/rows using the SQL Server security model.
Probably you'll want to use a combination of both.
SQL Server 2005 has encryption functions built-in, so take a look at
the encryption topics in Books Online. In earlier versions you can use
third party software to achieve the same thing.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||John,
Can I get a copy of dbo.fn_jiggerypokery()?
With a name like that, it 'sounds' interesting...
;-)
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:E64B9234-AACC-4453-998E-21ACCFA81699@.microsoft.com...[vbcol=seagreen]
> Hi
> If you wish to make the data anonymous then you will need an algorithm
> that
> is not easily breakable. Normal encryption procedures would not
> necessarily
> give you the format you want, but just moving numbers or replacement may
> not
> give you the require level of obfuscation.
> To change multiple values of a given column you can add an extra column
> say
> hasbeenchange which you set then the data has been changed. You can then
> cursor through the records in the table and change each value that does
> not
> already have hasbeenchange set
> DECLARE @.ssn char(9)
> DECLARE ssn_cursor CURSOR FOR
> SELECT ssn
> FROM Mytable WHERE hasbeenchange = 0
> ORDER BY SSN
> OPEN ssn_cursor
> FETCH NEXT FROM ssn_cursor INTO @.ssn
> WHILE @.@.FETCH_STATUS = 0
> BEGIN
> UPDATE mytable
> SET ssn = fn_jiggerypokery(ssn)
> WHERE ssn = @.ssn
> AND hasbeenchange = 0
> FETCH NEXT FROM ssn_cursor INTO @.ssn
> END
> CLOSE ssn_cursor
> DEALLOCATE ssn_cursor
> John
> "dmalhotr2001@.yahoo.com" wrote:
>

scramble ssn with sql server

Hi,
I'm trying to scramble the ssn#s within our database. I would need a 9
digit number to be converted into another 9 digit number in our dev
database.
Example #1:
ssn: 123456789 converts to 987654321
Also there is a catch, there is a possibility that there could be
duplicate ssn within a table due to bad data. I was the 2 records with
the same actual ssn# to be converted into the same scrambled ssn# using
sql server (so that the scrambled ssn#s match) for this issue.
Is there a way to do this?
Thanks
:DI hope you are not thinking about reversing the SSN in order to protect the
data? Any third grader could figure that out and would know all the SSNs.
Your best bet would be to replace them with actual random IDs. You might
try this approach...
Assuming you have SSN stored in one table, lets call it CUSTOMERS...
create a new table SSN_MASK. Insert into this table every unique SSN, along
with an identity column to give them a unique value. Then use the values in
this table to update SSN in the real table. Lastly, drop the SSN_MAsk table
(or at least truncate it) so no one can match the bogus SSNs to the real
thing.
create table SSN_MASK
(
NEW_SSN integer identity primary key not null,
OLD_SSN varchar(9) -- not sure how you defined it
);
insert into SSN_MASK (OLD_SSN) (select unique SSN from CUSTOMERS);
update CUSTOMERS
set SSN = (select
right('000000000' + cast(a.NEW_SSN as varchar(9)),9)
-- make sure the new SSN is 9 characters
from SSN_MASK as a
where a.OLD_SSN = CUSTOMERS.SSN);
drop table SSN_MASK;
<dmalhotr2001@.yahoo.com> wrote in message
news:1158351116.321489.122450@.i3g2000cwc.googlegroups.com...
> Hi,
> I'm trying to scramble the ssn#s within our database. I would need a 9
> digit number to be converted into another 9 digit number in our dev
> database.
> Example #1:
> ssn: 123456789 converts to 987654321
>
> Also there is a catch, there is a possibility that there could be
> duplicate ssn within a table due to bad data. I was the 2 records with
> the same actual ssn# to be converted into the same scrambled ssn# using
> sql server (so that the scrambled ssn#s match) for this issue.
> Is there a way to do this?
> Thanks
> :D
>

scramble ssn with sql server

Hi,
I'm trying to scramble the ssn#s within our database. I would need a 9
digit number to be converted into another 9 digit number in our dev
database.
Example #1:
ssn: 123456789 converts to 987654321
Also there is a catch, there is a possibility that there could be
duplicate ssn within a table due to bad data. I was the 2 records with
the same actual ssn# to be converted into the same scrambled ssn# using
sql server (so that the scrambled ssn#s match) for this issue.
Is there a way to do this?
Thanks
:DI hope you are not thinking about reversing the SSN in order to protect the
data? Any third grader could figure that out and would know all the SSNs.
Your best bet would be to replace them with actual random IDs. You might
try this approach...
Assuming you have SSN stored in one table, lets call it CUSTOMERS...
create a new table SSN_MASK. Insert into this table every unique SSN, along
with an identity column to give them a unique value. Then use the values in
this table to update SSN in the real table. Lastly, drop the SSN_MAsk table
(or at least truncate it) so no one can match the bogus SSNs to the real
thing.
create table SSN_MASK
(
NEW_SSN integer identity primary key not null,
OLD_SSN varchar(9) -- not sure how you defined it
);
insert into SSN_MASK (OLD_SSN) (select unique SSN from CUSTOMERS);
update CUSTOMERS
set SSN = (select
right('000000000' + cast(a.NEW_SSN as varchar(9)),9)
-- make sure the new SSN is 9 characters
from SSN_MASK as a
where a.OLD_SSN = CUSTOMERS.SSN);
drop table SSN_MASK;
<dmalhotr2001@.yahoo.com> wrote in message
news:1158351116.321489.122450@.i3g2000cwc.googlegroups.com...
> Hi,
> I'm trying to scramble the ssn#s within our database. I would need a 9
> digit number to be converted into another 9 digit number in our dev
> database.
> Example #1:
> ssn: 123456789 converts to 987654321
>
> Also there is a catch, there is a possibility that there could be
> duplicate ssn within a table due to bad data. I was the 2 records with
> the same actual ssn# to be converted into the same scrambled ssn# using
> sql server (so that the scrambled ssn#s match) for this issue.
> Is there a way to do this?
> Thanks
> :D
>|||>> create table SSN_MASK
(EW_SSN integer identity primary key not null,
OLD_SSN varchar(9)); -- not sure how you defined it <<
SSN is always CHAR(9). Simply numbering it with a proprietary feature
is not that good; you have destroyed the data type. Here is one we
used in procedural code with arrays.
CREATE TABLE SSN_masks
(shift_id INTEGER NOT NULL PRIMARY KEY -- cols 8 & 9
CHECK (shift_id BETWEEN 00 AND 99),
col1 INTEGER NOT NULL,
col2 INTEGER NOT NULL,
col3 INTEGER NOT NULL,
col4 INTEGER NOT NULL,
col5 INTEGER NOT NULL,
col6 INTEGER NOT NULL,
col7 INTEGER NOT NULL);
You take the last two digits of the SSN (fastest changing values) and
look up a vector that tells you how to shift the remaining seven
digits.
shift(x) = ABS((x + col_n) % 11-10)
Since you have 100 different masks, the data gets scrambled pretty good
and it destroys the area digits which would otherwise repeat and give
information about the population geographic distribution. This is also
reversible because we preserve the shift identifier in the output;
shift all of them and it is a bitch to unscramble without the shift
array. Then you change the array when you get the next sample.

scramble ssn with sql server

Hi,
I'm trying to scramble the ssn#s within our database. I would need a 9
digit number to be converted into another 9 digit number in our dev
database.
Example #1:
ssn: 123456789 converts to 987654321
Also there is a catch, there is a possibility that there could be
duplicate ssn within a table due to bad data. I was the 2 records with
the same actual ssn# to be converted into the same scrambled ssn# using
sql server (so that the scrambled ssn#s match) for this issue.
Is there a way to do this?
Thanks
:DHi
If you wish to make the data anonymous then you will need an algorithm that
is not easily breakable. Normal encryption procedures would not necessarily
give you the format you want, but just moving numbers or replacement may not
give you the require level of obfuscation.
To change multiple values of a given column you can add an extra column say
hasbeenchange which you set then the data has been changed. You can then
cursor through the records in the table and change each value that does not
already have hasbeenchange set
DECLARE @.ssn char(9)
DECLARE ssn_cursor CURSOR FOR
SELECT ssn
FROM Mytable WHERE hasbeenchange = 0
ORDER BY SSN
OPEN ssn_cursor
FETCH NEXT FROM ssn_cursor INTO @.ssn
WHILE @.@.FETCH_STATUS = 0
BEGIN
UPDATE mytable
SET ssn = fn_jiggerypokery(ssn)
WHERE ssn = @.ssn
AND hasbeenchange = 0
FETCH NEXT FROM ssn_cursor INTO @.ssn
END
CLOSE ssn_cursor
DEALLOCATE ssn_cursor
John
"dmalhotr2001@.yahoo.com" wrote:
> Hi,
> I'm trying to scramble the ssn#s within our database. I would need a 9
> digit number to be converted into another 9 digit number in our dev
> database.
> Example #1:
> ssn: 123456789 converts to 987654321
>
> Also there is a catch, there is a possibility that there could be
> duplicate ssn within a table due to bad data. I was the 2 records with
> the same actual ssn# to be converted into the same scrambled ssn# using
> sql server (so that the scrambled ssn#s match) for this issue.
> Is there a way to do this?
> Thanks
> :D
>|||dmalhotr2001@.yahoo.com wrote:
> Hi,
> I'm trying to scramble the ssn#s within our database. I would need a 9
> digit number to be converted into another 9 digit number in our dev
> database.
> Example #1:
> ssn: 123456789 converts to 987654321
>
> Also there is a catch, there is a possibility that there could be
> duplicate ssn within a table due to bad data. I was the 2 records with
> the same actual ssn# to be converted into the same scrambled ssn# using
> sql server (so that the scrambled ssn#s match) for this issue.
> Is there a way to do this?
> Thanks
> :D
For what purpose do you want to do this? One reason might be that you
want to generate some test data without compromising any confidential
information. In that case you could use the CHECKSUM or RAND functions
to generate some arbitrary values.
Another reason might be that you want to secure the data. "Scrambling"
a number has nothing to do with any meaningful kind of security so here
are some other suggestions instead. You can encrypt the data and/or to
limit access to column/rows using the SQL Server security model.
Probably you'll want to use a combination of both.
SQL Server 2005 has encryption functions built-in, so take a look at
the encryption topics in Books Online. In earlier versions you can use
third party software to achieve the same thing.
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||John,
Can I get a copy of dbo.fn_jiggerypokery()?
With a name like that, it 'sounds' interesting...
;-)
--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:E64B9234-AACC-4453-998E-21ACCFA81699@.microsoft.com...
> Hi
> If you wish to make the data anonymous then you will need an algorithm
> that
> is not easily breakable. Normal encryption procedures would not
> necessarily
> give you the format you want, but just moving numbers or replacement may
> not
> give you the require level of obfuscation.
> To change multiple values of a given column you can add an extra column
> say
> hasbeenchange which you set then the data has been changed. You can then
> cursor through the records in the table and change each value that does
> not
> already have hasbeenchange set
> DECLARE @.ssn char(9)
> DECLARE ssn_cursor CURSOR FOR
> SELECT ssn
> FROM Mytable WHERE hasbeenchange = 0
> ORDER BY SSN
> OPEN ssn_cursor
> FETCH NEXT FROM ssn_cursor INTO @.ssn
> WHILE @.@.FETCH_STATUS = 0
> BEGIN
> UPDATE mytable
> SET ssn = fn_jiggerypokery(ssn)
> WHERE ssn = @.ssn
> AND hasbeenchange = 0
> FETCH NEXT FROM ssn_cursor INTO @.ssn
> END
> CLOSE ssn_cursor
> DEALLOCATE ssn_cursor
> John
> "dmalhotr2001@.yahoo.com" wrote:
>> Hi,
>> I'm trying to scramble the ssn#s within our database. I would need a 9
>> digit number to be converted into another 9 digit number in our dev
>> database.
>> Example #1:
>> ssn: 123456789 converts to 987654321
>>
>> Also there is a catch, there is a possibility that there could be
>> duplicate ssn within a table due to bad data. I was the 2 records with
>> the same actual ssn# to be converted into the same scrambled ssn# using
>> sql server (so that the scrambled ssn#s match) for this issue.
>> Is there a way to do this?
>> Thanks
>> :D
>>

scramble password

Hello group,
I have a fairly simple question (hopefully simple anyway). I have a table
that has basic application user data: name, address, city, email, password.
I now have a requirement to in bulk take the password and encrypt them. The
y
have already given me the function name to use: ToBase64Sting().
Here is the question; how can I run the password field into this function in
a stored procedure? I am not familier with this function but have done some
reading. I suspect I would just place the scrambled password into a second
field and delete the original, then rename the field. Any suggestions?update YourTable
set password = dbo.ToBase64Sting(password)
try doing this first and look at the the 2 fields
select password ,dbo.ToBase64Sting(password ) from YourTable
http://pixsells.blogspot.com
"Rich" wrote:

> Hello group,
> I have a fairly simple question (hopefully simple anyway). I have a table
> that has basic application user data: name, address, city, email, password
.
> I now have a requirement to in bulk take the password and encrypt them. T
hey
> have already given me the function name to use: ToBase64Sting().
> Here is the question; how can I run the password field into this function
in
> a stored procedure? I am not familier with this function but have done so
me
> reading. I suspect I would just place the scrambled password into a secon
d
> field and delete the original, then rename the field. Any suggestions?|||Rich wrote:
> Hello group,
> I have a fairly simple question (hopefully simple anyway). I have a
> table that has basic application user data: name, address, city,
> email, password. I now have a requirement to in bulk take the
> password and encrypt them. They have already given me the function
> name to use: ToBase64Sting().
> Here is the question; how can I run the password field into this
> function in a stored procedure? I am not familier with this function
> but have done some reading. I suspect I would just place the
> scrambled password into a second field and delete the original, then
> rename the field. Any suggestions?
Is the function they gave you a SQL Server callable function? If so, you
can just update the table directly, assuming the return value from the
function (which is likely just ASCII) is compatible with the data type
you are using for the column in the table. Something like:
Update
dbo.MyTable
Set
Password = dbo.ToBase64String(Password)
BTW, why are you storing passwords in the database? Base64 is not an
encryption scheme. It is an encoding scheme, used mainly by email system
to send attachments. Base64 is not secure and anyone with internet
access will be able to turn that Base64 value into the original
password. So, you may want to reconsider storing passwords in the
database.
David Gugick
Quest Software
www.imceda.com
www.quest.com|||Hello David,
see http://support.microsoft.com/defaul...kb;en-us;317535
I thought that this function would be available from the SQL Server however
this function does not appear to be part of TSQL. I tried the code fragment
you posted and I am thinking this will not work. This functionis something
the my web developers I work with are using so you comment about being secur
e
over the web scares me...
Rich
"David Gugick" wrote:

> Rich wrote:
> Is the function they gave you a SQL Server callable function? If so, you
> can just update the table directly, assuming the return value from the
> function (which is likely just ASCII) is compatible with the data type
> you are using for the column in the table. Something like:
> Update
> dbo.MyTable
> Set
> Password = dbo.ToBase64String(Password)
> BTW, why are you storing passwords in the database? Base64 is not an
> encryption scheme. It is an encoding scheme, used mainly by email system
> to send attachments. Base64 is not secure and anyone with internet
> access will be able to turn that Base64 value into the original
> password. So, you may want to reconsider storing passwords in the
> database.
>
> --
> David Gugick
> Quest Software
> www.imceda.com
> www.quest.com
>|||I see what you are doing we used to do the same
You use .NET encryption the function you mentioned is a .NET function
Have one of your web guys write a script to loop through the table and
update the password with the encrypted string
There is no way you can do this in SQL server 2000 (as far as I know that is
)
http://sqlservercode.blogspot.com/
"Rich" wrote:
> Hello David,
> see http://support.microsoft.com/defaul...kb;en-us;317535
> I thought that this function would be available from the SQL Server howeve
r
> this function does not appear to be part of TSQL. I tried the code fragme
nt
> you posted and I am thinking this will not work. This functionis somethin
g
> the my web developers I work with are using so you comment about being sec
ure
> over the web scares me...
> Rich
> "David Gugick" wrote:
>|||Hello SQL,
yes, yes, yes, you understand! I just need a loop to update that field with
that function they suggested! The problem is I will end up make the "loop".
I am looking at making this looper in MSAccess, connect to the table, run th
e
loop and be done with this. I just need to understand if this is a standard
VB function that I can drop the field into the function and let the thing
return the encrypted password.
Rich
"SQL" wrote:
> I see what you are doing we used to do the same
> You use .NET encryption the function you mentioned is a .NET function
> Have one of your web guys write a script to loop through the table and
> update the password with the encrypted string
> There is no way you can do this in SQL server 2000 (as far as I know that
is)
> http://sqlservercode.blogspot.com/
>
> "Rich" wrote:
>|||I don't know if MS Access will work
We used C# ASP.NET but I was not involved with this process
I don't know if MS Access can access those functions since they are .NET
specific
try one of the .NET newsgroups for this question
http://sqlservercode.blogspot.com/
"Rich" wrote:
> Hello SQL,
> yes, yes, yes, you understand! I just need a loop to update that field wi
th
> that function they suggested! The problem is I will end up make the "loop
".
> I am looking at making this looper in MSAccess, connect to the table, run
the
> loop and be done with this. I just need to understand if this is a standa
rd
> VB function that I can drop the field into the function and let the thing
> return the encrypted password.
> Rich
> "SQL" wrote:
>|||Store a hash of the password not the password itself. Hash the input and
compare both hashes to determine if they are the same. There are some
undocumented hash functions in SQL (don't remember the names) but you really
should hash it then send it to the server for comparison rather than send
the plain text password across the wire.
Derek Davis
ddavis76@.gmail.com
"SQL" <SQL@.discussions.microsoft.com> wrote in message
news:F32DD3BB-A829-456F-AF2A-18AA6D1FEEDB@.microsoft.com...
>I don't know if MS Access will work
> We used C# ASP.NET but I was not involved with this process
> I don't know if MS Access can access those functions since they are .NET
> specific
> try one of the .NET newsgroups for this question
> http://sqlservercode.blogspot.com/
>
> "Rich" wrote:
>

SCPTXFR.EXE-- Problem with Drop procedure

hi there
I am using SCPTXFR.EXE to generate script of the database(for backup),using following command.

SCPTXFR.EXE /s abc /d aaa /P abc12345 /f D:\HSE0607\SCHEMA.sql /q/r/T

Now the script is generating fine, but what i find that there is no statment like
"if not exists(...) "
for the Stored Procedure( i had applied the /r parameter), for the Create Tables it is there.

Why there is no statment IF NOT EXISTS(...) for Stored Procedure?
I need this Line, how can i do this?
Regards,
Thanks.
Gurpreet S. Gill

hey nobody help me here, but i find the solution at

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=73290

scptxfr.exe - generated script fails

Generated script fails because fucntions are added to this script after
tables in which this functions can be used for calculated column.
How can I resolve this?
Is there any usefull tool that can generate script with proper order of
dependence objects?
|||Download DataStudio from http://www.agileinfollc.com, it has very strong
scripting capability.
"Sergi Adamchuk" <adamchuk@.gmail.com> wrote in message
news:1124378725.452117.32190@.g47g2000cwa.googlegro ups.com...
> Is there any usefull tool that can generate script with proper order of
> dependence objects?
>
|||Can it do exactly that I need. It is 7 MB very big for me. I would like
to know weather this soft can do my work before downloading. Does
avaluatin versiong it?
|||DataStudio has evaluation version (http://www.agileinfollc.com/product.asp),
you can install and try it before you buy.
John King
http://www.agileinfollc.com
"Sergi Adamchuk" <adamchuk@.gmail.com> wrote in message
news:1124459262.366497.216500@.g47g2000cwa.googlegr oups.com...
> Can it do exactly that I need. It is 7 MB very big for me. I would like
> to know weather this soft can do my work before downloading. Does
> avaluatin versiong it?
>
|||I downloaded evaluation version. This software DOES NOT make working
SQL script for database creation. ((
The problem is still opened.
|||Can I temprally disable error rising if I'am creating a table that has
in its default value nonexisting function?

scptxfr.exe

Hello Experts,
I have some Table names and fields in my language (Greek)
and when I use the scptxfr.exe utility to script my DB
then I see "chinese" (Greek argot and maybe yours too). I
try place the Code Page but it didn't worked.
Do you have any suggestions how to resolve this problem?
Is it a good (which scripts hierachical) tool to script
my whole DB?
PS: I got SQL Server 2000 (latest Service Pack)
Thanks in advance.
Konstantinos MichasHi Konstantinos,
Have you tried running the program with the UNICODE
switch ?
That should make it collation independant.
J
>--Original Message--
>Hello Experts,
>I have some Table names and fields in my language (Greek)
>and when I use the scptxfr.exe utility to script my DB
>then I see "chinese" (Greek argot and maybe yours too). I
>try place the Code Page but it didn't worked.
>Do you have any suggestions how to resolve this problem?
>Is it a good (which scripts hierachical) tool to script
>my whole DB?
>PS: I got SQL Server 2000 (latest Service Pack)
>Thanks in advance.
>Konstantinos Michas
>.
>|||Hello Julie and thanks for your reply, it works fine know.
Thanks again!
Konstantinos Michas
>--Original Message--
>Hi Konstantinos,
>Have you tried running the program with the UNICODE
>switch ?
>That should make it collation independant.
>J
>
>>--Original Message--
>>Hello Experts,
>>I have some Table names and fields in my language
(Greek)
>>and when I use the scptxfr.exe utility to script my DB
>>then I see "chinese" (Greek argot and maybe yours too).
I
>>try place the Code Page but it didn't worked.
>>Do you have any suggestions how to resolve this
problem?
>>Is it a good (which scripts hierachical) tool to script
>>my whole DB?
>>PS: I got SQL Server 2000 (latest Service Pack)
>>Thanks in advance.
>>Konstantinos Michas
>>.
>.
>

scptxfr problems on sql 2005

Having used the scptxfr utility successfully on Sql 2000, I am trying to use it against sql 2005. I have had mixed results, in simple databases this seems to work ok however in complex databases the utility appears to hang, has any one had this problem or knows of a workaround?

Scptxfr.exe was a tool included with SQL Server 7.0 and 2000, but not with 2005. One option I've heard people using is located here:

http://www.codeplex.com/Wiki/View.aspx?ProjectName=sqlhost&title=Database%20Publishing%20Wizard

Thanks,
Sam Lester (MSFT)

|||In my experience it worked in SQL 2005 RTM earlier and after that had similar problem.|||

The tool probably works great in some situations with SQL 2005, but is not included with the product and thus not supported. I'd suggest trying some of the other supported tools.

Thanks,
Sam