Hello @ADX ,
Thanks for the ask and using Microsoft Q&A platform .
I have replied to something similar here . https://stackoverflow.com/questions/65833908/syntax-error-when-using-input-parameter-to-create-procedure/65895040#65895040
Adding the comment here for completedness .
This should work . I have created the Copy command dynamically and passing the SAS token to that . Once I have the copy command created I execute the command . The print statement , i used it as a test
CREATE PROCEDURE dbo.bulk_load
anonymous user_token VARCHAR(500)
AS
BEGIN
--DECLARE anonymous user varchar(500)
--SET anonymous user = ''''+ anonymous user_token + ''''
declare @Query varchar(max)
IF OBJECT_ID('dbo.ITEM_INFORMATION') IS NOT NULL
DROP TABLE dbo.ITEM_INFORMATION
;
CREATE TABLE dbo.ITEM_INFORMATION
(
SSN VARCHAR(20),
Name VARCHAR(15)
);
SELECT @query ='
COPY INTO dbo.ITEM_INFORMATION
FROM ''https://server.blob.core.windows.net/container/subfolder/file.csv''
WITH (FILE_TYPE = ''CSV'',
FIELDTERMINATOR = ''',''',
FIRSTROW = 2,
ROWTERMINATOR = ''\n'',
CREDENTIAL = (
IDENTITY = ''Shared Access Signature'',
SECRET = '''+*anonymous user*_token+'''
)
);'
print @query
exec(@query)
END
Please do let me know how it goes .
Thanks
Himanshu
-------------------------------------------------------------------------------------------------------------------------
- Please don't forget to click on or upvote button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
- Want a reminder to come back and check responses? Here is how to subscribe to a notification
- If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators