Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Replace column with random data

Author  Topic 

petek
Posting Yak Master

192 Posts

Posted - 2009-07-14 : 02:46:20
Hi,

Firstly thanks for looking......;

I need to replace column data from my production server to my test box.

Is there a way replace the column data with random data?

cheers

Pete

Kind Regards

Pete.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-14 : 03:03:47
you have to write a query to do that. Make use of rand() or newid() to generate random data


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

petek
Posting Yak Master

192 Posts

Posted - 2009-07-14 : 03:25:31
Hi have something like .......

select top 10 newid() as [ContactName], [ContactName], [ContactTitle]
FROM [Northwind].[dbo].[Customers]

this generates a uniqueidentifier; can this be modified to use less letters???

ideally i need to mix the contents up....

Kind Regards

Pete.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-14 : 03:31:43
use LEFT() to limit the numbers of required characters

select left(convert(varchar(38), newid()), 10)



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-07-14 : 03:33:40
http://sqlblogcasts.com/blogs/madhivanan/archive/2008/04/04/populating-sample-data.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

petek
Posting Yak Master

192 Posts

Posted - 2009-07-14 : 03:58:59
Thanks both for your input.....both great help.

but i lets say i have two columns [FirstName] and [SecondName] and i want to generate date from them.

ideally i would like to replace FirstName with SecondName and then randomally sort both columns with a update.....

Kind Regards

Pete.
Go to Top of Page

waterduck
Aged Yak Warrior

982 Posts

Posted - 2009-07-14 : 04:36:00
hi, madhi...sorry t bother...can you explain abit to me what is checksum...i looks at books online and it looks like something to do with index(don't understand index at all)sorry sorry


Hope can help...but advise to wait pros with confirmation...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-07-14 : 05:05:23
quote:
Originally posted by waterduck

hi, madhi...sorry t bother...can you explain abit to me what is checksum...i looks at books online and it looks like something to do with index(don't understand index at all)sorry sorry


Hope can help...but advise to wait pros with confirmation...


http://www.mssqltips.com/tip.asp?tip=1023

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-07-14 : 05:06:30
quote:
Originally posted by petek

Thanks both for your input.....both great help.

but i lets say i have two columns [FirstName] and [SecondName] and i want to generate date from them.

ideally i would like to replace FirstName with SecondName and then randomally sort both columns with a update.....

Kind Regards

Pete.


Post some sample data with expected result

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

waterduck
Aged Yak Warrior

982 Posts

Posted - 2009-07-14 : 05:16:40
thx madhi ^^


Hope can help...but advise to wait pros with confirmation...
Go to Top of Page
   

- Advertisement -