I'm using ASP and SQL Serv 2000. What I need to get from 2 tables (company & customers) is random 10 customers from random 20 comp.
Anyone got an idea how to do this??? I've spent 2 days trying to get stored proc. or T-SQL to work, but nothing good came out of it. I can get 1 comp and 10 cust, but not a grouped list of 20 comp. w/ 10 cust. each.
Hi,I need to extract randomly 5 records from the table "Questions". Now I useSELECT TOP 5 FROM Questions ORDERBY NEWID()And it works. The problem is that I need an additional thing: if SQLextracts record with ID=4, then it should not extract record with ID=9,because they are similar. I mean, I'd like something to tell SQL that if itextracts some questions, then it SHOULD NOT extract other ones.How can I do it?Thanks!Luke
select * from ldap_users as PL where (emcidentitytype like '%P%') and(ctscUserKeywords NOT LIKE '%LockedOut%') AND(ctscUserKeywords NOT LIKE '%LockedOut%') and emclastdayworked = '' and (uid in(select fax from oracle_11i_user) or uid in (select fax from ORACLE_1103_USER))
This query only display all the fields from PL. I want to display end_date from both oracle11i and oracle1103 tables? How would I do that?
Hi there.I need to fetch ONE random row from many. How can i get it? I try toexecute "SELECT field.table FROM table ORDER by RAND()" no effect.Thank you.
Hy, I nead to make a stored procedure in order to add a random record set. This record set is used to write in an ASP page a list which is automatically modified everytime we reload the page.
I'm trying to use the following query to select two random records from my database. Do you have any ideas of why the recrand field will not change? I am using MS Sql server 7.. Please email mark@dtdesign.com ..Cheers Mark
SELECT TOP 2 mytable.id AS RECID, RAND(mytable.id) AS recrand FROM mytable ORDER BY recrand
Has anyone noticed that if you created DTS package and try to change connection properties (i.e. change DSN or redirect DTS to different server or Database), as soon you click OK it does not save new password and hence does not work anymore. In my case to move Database from Development to Production server I would have to recreate all DTS packages. Is there any way around it?
I am trying to get random numbers to have a unique value for different processes, then I can identify each process. What happens is that I use rand() function without seed, so I got my random numbers, but after shutting down SQLServer and try to get again another random number after booting up, the same series of random numbers is given again and again. So if anyone knows how I can get unique values,even though reseting the server, and using random function or any other method which automatically provides unique values,I'll really appreciate it if you let me know it.
Is there a way to write an SQL statement to choose random values from a particular select statement..for example: select * from address I was thinking, if there was a way to use an include statement for it like: select * from address where id IN ('generates some random values')
So i've got to generate these queries that go from the first of a one month to the last day of a month. the user provides the starting and ending months.
What I was wondering was is there an easy way to set the last day of the month in sql without having to go in and hard code which months end on the 30 and which ones end on the 31.
I once came across a database in which when ever a row was inserted, a unique random code was also inserted in a column. This code generated was similar to format like {8A5FE5F1-6BDA-476C-A4DB584A7710FBF91121054625}. I was told that SQL2000 has some inbuilt functionality for this.
Any idea on how to do this using SQL2000 or coding. I feel this is much better than Identity Column as using autonumbers in quesrystring is too much risky as they easily readable.
I have a table with 3 fields SiteID (PK), SiteCode, SiteName. For each SiteCode I have several rows with different SiteName. For example: 1 327 a 2 327 b 3 327 c 4 328 aa 5 328 bb......
I need to retrieve each time SiteCode with random SiteName. For example: 327 b , 327 a , 327 c 328 aa 328 bb 328 aa.
I need it very urgent, so any ideas will be very helpful. Thanks to all,
I have a customer that wants to be able to generate a random list... ----------------------- The list is case numbers, and I can get those easy enough by saying
SELECT dbo.table_case.id_number FROM dbo.table_case
Now, what I want to do is take that list and extract 1 out of every 1000, picking out random id_numbers to display.
Hi Experts , I want to insert datas randomly to all columns of a table.The columns have different datatypes like int,varchar,datetime. What to do??? It is urgent so please help.
Hi Experts , I want to insert datas randomly to all columns of a table.The columns have different datatypes like int,varchar,datetime. How to create a procedure for the same??? please help.
I used this to generate a random password. You can change what it returns to up to an 8000 character password if you feel brave. You will need this function (http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=14924) to generate the random numbers. For some reason, occassionaly a NULL (CHAR(0)) character would get in there and mess things up so I had to remove those. You could change this to even include the non alpha numeric characters.
create procedure random_password @length smallint, @password nvarchar(256) = null output as set nocount on
declare @number int declare @lower int declare @upper int declare @part tinyint
if @length > 256 set @length = 256 set @password = ''
while len(@password) < @length begin exec random_number 0, 3, @part output
set @part = null set @number = null exec random_number @lower, @upper, @number output set @password = @password + ltrim(char(@number)) if substring(@password, len(@password), 1) = char(0) set @password = left(@password, len(@password) - 1) end go
I need to update an integer column in my table with a random number. Here's what I've done so far (with the table name and column names changed):
UPDATE dbo.MyTable SET Column1 = RAND() * 1000000
My question is, how come the values in my column all have the same value? I thought the RAND function gives out a random number? How can I update my table to generate random numbers?
I am new to TSQL and any help on the following would be appreciated.
I have a table that looks like this security Message 2345 Good 2346 Good uoas Bad fsaf More sdad More asdd More ndgs More
I have to pull in a list of distinct messages with a count and any 3 cusips that belong to the message.
I have written, something like this
SELECT MESSAGE_TEXT, COUNT(*) AS Expr1, MIN(security) AS Expr2, MAX(SECURITY) AS Expr3 FROM dbo.DerivedSIACDataMessages GROUP BY MESSAGE_TEXT ORDER BY COUNT(*) DESC
However, this lets me pull only 2 securities per message and I want to pull in 4 cusips.
Hi every one.How can I get random 4 records in my table. Example I want to get top 4 random records Select top 4 from tbl_Products.....? Thanks in appreciate
Hi all! I have a table with three columns: Identity, DateTime (current_timestamp) and one which I want to fill with random values always depending on the value in the same column one row above.
Since I want it to be a stored procedure I have to pass three parameters - an initial value, the range within the random number is higher or lower than the number in the preceding row and the number of rows which should be inserted. This means that as soon as a new row is inserted there is also a new seed for the random value for the next line.
My problem now is that I would always get out the same number. Maybe you know a solution for my problem.
I want to have a SELECT statement in stored procedure to make a random ORDER every time it runs, so one time ORDER BY first_name, then maybe person_telephone, then maybe per created_date, etc..
Can anyone tell my why I'm getting these first few errors? IT seems to be preventing my SQl Agent from successfully firing off my SSIS package:
01/04/2006 09:53:48,,Warning,[396] An idle CPU condition has not been defined - OnIdle job schedules will have no effect 01/04/2006 09:53:48,,Warning,[260] Unable to start mail session (reason: No mail profile defined) 01/04/2006 09:53:48,,Information,[129] SQLSERVERAGENT starting under Windows NT service control 01/04/2006 09:53:48,,Error,[364] The Messenger service has not been started - NetSend notifications will not be sent
i want to anonymous data by multiplicating with a random generated value. After a little bit research i know that is only solvable with a script task, but i dont have seen a working example script. Does anybody knows where i can found a little scriptlet or post something? Thank you!