I have a list of raw IDs that I am supposed to put into a temp table. I am unsure about how this works in SQL Server:
I know the general format:
select PID into #myPIDs
from ... ?
I already have a list of about 30 PIDs which I am to use. They look like so:
'U388279963',
'U388631403',
'U389925814'
How do I go about doing this? Thanks!
No, there is no records limit for temporary table (the limit is the disk space). But be careful, because temporary tables are physically created in tempdb database, and this database must be placed on the disk with appropriate size.
To create a Global Temporary Table, add the “##” symbol before the table name. Global Temporary Tables are visible to all connections and Dropped when the last connection referencing the table is closed. Global Table Name must have an Unique Table Name.
Question: All objects can have minimum 1 and maximum of 128 characters in their names in SQL Server. Only exception is local, temporary tables that can have a maximum of 116 characters.
Your format will work for creating a new temp table for one insert. If you need to copy and paste your IDs then the following will work.
CREATE TABLE #myPIDs
(
PID VARCHAR(30)
);
INSERT INTO #myPIDs
VALUES
(....),
(....);
Copy and paste your PIDs and use find and replace with regular expressions to replace each line with the regular expression option checked. Remove the last ',' and you're good.
Find - ^{U:z+}$
Replace - ('\1'),\n
Alternatively you can have sql server read your ids from a file on the system. If you elaborate on your needs I can give you a better answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With