Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an Access equivalent of the SQL Server NewId() function?

I have written SQL statements (stored in a text document) that load data into a SQL Server database. These statements need to be repeated daily. Some of the statements use the NewId() function to populate a keyed field in the database, and this works fine.

While I'm in the process of writing an application to replicate these statements, I want to use Access queries and macros instead of copying and pasting queries into SQL Server, thus saving me time on a daily basis. All is working fine but I can't find any function that will replace the SQL Server NewId() function. Does one exist or is there a work around?

I'm using SQL Server 2005 and Access 2007.

like image 808
user66061 Avatar asked Mar 03 '09 17:03

user66061


People also ask

How do I get Newid in SQL?

Using NEWID in a CREATE TABLE statement. The following example creates the cust table with a uniqueidentifier data type, and uses NEWID to fill the table with a default value. In assigning the default value of NEWID() , each new and existing row has a unique value for the CustomerID column.

Is Newid unique in SQL Server?

In SQL Server, you can use the NEWID() function to create a unique value. More specifically, it's an RFC4122-compliant function that creates a unique value of type uniqueidentifier. The value that NEWID() produces is a randomly generated 16-byte GUID (Globally Unique IDentifier).

What is the use of Newid in SQL?

The NEWID() function in SQL Server creates a unique value of type uniqueidentifier. One use of the NEWID() function is in generating random rows from a table.

How long is newid () in SQL?

It can store 16 bytes of data.


1 Answers

On top of matt's answer, you could simply use a pass-through query and just use your existing, working queries from MS Access.

like image 115
Renaud Bompuis Avatar answered Sep 29 '22 19:09

Renaud Bompuis