Showing posts with label namei. Show all posts
Showing posts with label namei. Show all posts

Monday, March 26, 2012

Making random names!

Hi
I have no idea but want to learn it how to make random names with sql server...
I have a table, called table1, for colums Firstname and Last name
I want it to make random names, so much it is possible it can get, in table2 where the colums is named Names
PLEASE HELP :)

knuff--

Regardign this...

knuff wrote:

...I have no idea but want to learn it how to make random names with sql server...

...I say, I am just guessing (and yet I think this is quite possible)...

...I expect that one could use these TSQL functions...

RAND ( [ seed ] )
Returns a random float value from 0 through 1.

ROUND ( numeric_expression , length [ , function ] )
Returns a numeric expression, rounded to the specified length or precision.

CHAR ( int )
A string function that converts an int ASCII code to a character.

...and some string contatenation to get the job done.

That said, I will add that doing something like this is MUCH better suited to middle-tier logic rather than the database, IMHO.

HTH.

Thank you.

--Mark Kamoski

|||Ok... Sounds logical to me what you wrote there i can try out of that

Monday, March 12, 2012

make a copy of a db

I need to restore a copy of database to a new db name

i'm trying by creating a new db and restoring by doing

RESTORE DATABASE [userr] FROM DISK = N'D:\sqlbackups\user.bak' WITH FILE = 4, NOUNLOAD, STATS = 10
GO

i'm getting an error

Msg 3154, Level 16, State 4, Line 1
The backup set holds a backup of a database other than the existing 'userr' database.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

What's the best way to do this?Apparently what you believe to be FILE = 4 and what the RESTORE finds in FILE = 4 is not the database you believe it to be.

Post the results of RESTORE HEADERONLY for the backup device please, and let's work from there.

BTW is the name of the database you are looking for "user" or "userr"?|||If this restore is going on the same instance as the original database, you will also need to move the physical files in the restore command.|||what's restore headeronly?

i'm trying to restore a backup from user to userr|||i'm restoring to a new db.
I don't want to lose my backups or touch my regular db in anyway

what's the best way to do this?|||what's restore headeronly?

i'm trying to restore a backup from user to userr

Check BOL!!|||If this restore is going on the same instance as the original database, you will also need to move the physical files in the restore command.

True, but I figure one problem at a time ... the RESTORE command, as he provided it, is trying to pull one backup out of a backup set ... a database named 'userr' ... and RESTORE says it is not at file position 4. Once we find the correct backup, we will work with "WITH MOVE".|||Yeah, but userr is the destination name, not the source name. I agree there may be a problem with the backup file (such as no fileID 4), but restore should pick up whatever backup is in slot 4, and restore it under the new name. I have not fiddled with this bit, since backing up everything to one file is a bit riskier than I like, so I have never had a reason to experiment with it.|||so what is the best way to do this - I urgently need to restore to a new db.|||why dont you use the restore option from enterprise manager... It is lot more easier...|||Backup and restore is the best way.