Questions tagged [newid]

NEWID() is a SQL Server function which creates a unique value of type uniqueidentifier.

NEWID() is a SQL Server function which creates a unique value of type uniqueidentifier.

Reference

MSDN article

73 questions
0
votes
1 answer

NewID() taking long time to process

I am executing the code below for a table with 2 million plus records but NewID() is taking a long time to run. Can you suggest an alternate method to make the query faster? DELETE FROM Table1 WHERE ID NOT IN (SELECT TOP 60000 ID FROM Table1 WHERE…
Sam
  • 103
  • 7
0
votes
1 answer

Preventing duplicates with random rows and duplicates

I have a dataset where I need to randomly select x number of rows that meet certain criteria, x number of rows that meet other criteria, etc., and outputs the results all in one table. I've been using the following: SELECT * FROM (SELECT TOP 1000 *…
slk
  • 15
  • 4
0
votes
3 answers

SQL Server: update column with special characters

I'm new to SQL Server so please excuse me for maybe stupid question. I have a database that I need to generate random id which I achieve by using newid() insert into Teams (team_code, team_name, team_short) values (newid(),test,test) But the…
Greg
  • 1
  • 1
0
votes
2 answers

How to prevent duplicated records when applying ORDER BY NEWID() to fetch them randomly?

I tried using the solution provided in Return rows in random order to fetch random records in my query. But I have to add NEWID() to the list of columns I want to fetch or otherwise I will not be able to add ORDER BY NEWID() . Unfortunately it makes…
Farshid
  • 5,134
  • 9
  • 59
  • 87
0
votes
0 answers

Postgresql using uuid_generate_v1() generates error

I'm trying to run this query in postgresql: CREATE TABLE MMCompany ( CompanyID uuid PRIMARY KEY NOT NULL DEFAULT uuid_generate_v1(), Name VARCHAR (150) NOT NULL, PhoneNumber VARCHAR(20) NOT NULL, Email VARCHAR(100), CompanyLogo…
liv a
  • 3,232
  • 6
  • 35
  • 76
0
votes
1 answer

i am migrtaing database from sql server 2008 to teradata

I am migrating a database from Sql Server 2008 to Teradata and I am facing a problem: In Sql Server in the ddl of a table column is defined as follows: [rowguid] uniqueidentifier ROWGUIDCOL NOT NULL CONSTRAINT [DF_Address_rowguid] DEFAULT…
bhawuk chauhan
  • 21
  • 1
  • 1
  • 2
0
votes
0 answers

sql insert into table which uses newid in user defined function

Possible Duplicate: newid() inside sql server function I have to return a value based on parameter from the function which looks into the table and when it's null insert into this table new record. Unfortunately I'm getting this funny error: …
Zulu Z
  • 1,103
  • 5
  • 14
  • 27
-1
votes
1 answer

Duplicate Records with RAND() function

I have a python program to extract data from Microsoft SQL Server and load them to another table in the same database. Using this extraction program, I am trying to do the following. Get the input arguments from an excel file Fetch one random…
-1
votes
2 answers

NEWID() is generating bad format values in SQL Server

I'm generating unique identifier values using NEWID(). The problem is sometimes values are generating like "65687519-E612-4B86-A8D8-F44E53DD6EDC" The first part of unique identifier value is all numeric characters(65687519). This is creating some…
Gopal Biswas
  • 409
  • 1
  • 7
  • 34
-2
votes
1 answer

Unique Random Id using all 62 characters

I am looking for a way to generate unique random ids that will be as short as possible (similar to url shorteners) either through code or using MSSQL (preferable). I know this can be done using NEWID or CRYPT_GEN_RANDOM(), but these methods only use…
user1480192
  • 665
  • 8
  • 23
-2
votes
3 answers

Where is the official documentation for T-SQL's "ORDER BY RAND()" and "ORDER BY NEWID()"?

I'm looking for the official T-SQL documentation for "ORDER BY RAND()" and "ORDER BY NEWID()". There are numerous articles describing them, so they must be documented somewhere. I'm looking for a link to an official SQL Server documentation page…
Anechoic
  • 15
  • 3
-4
votes
1 answer

SQL - Case when lineid='01' then newid else id

I have this kind of data in my table lineid price € 01 100.00 02 200.00 01 10.34 01 311.12 01 14.33 02 36.44 03 89.70 04 11.33 and i would like my output to be like this docid lineid price…
Sokratis
  • 1
  • 1
-5
votes
1 answer

what is newID() in sql server?

what is newID() in sql server ?
Sairaj
  • 1
1 2 3 4
5