I Have to create a query in which I have to do many thing:
First check if table is already exist in the database or not
Second I have to check if it is not exist create it and then load the data from text file into database using bcp for that, if it is already created i have to rename it
SET@CMD='BCP db..'+@TableName+' IN file path -T -f -t,-c -E'
SQL
EXEC MASTER..XP_CMDSHELL @CMD
in this code suppose I have no table with name x so I m doing it for the first time, when I run it for the first time it will create a table with x when I run it second time it should update the existing one name with x_getdate() but it is creating new table, what i want is when it run for the second time it will update the existing table and load data in it.
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Nilesh ShahRank #42 · 34.2K reputationPosted Jun 28, 2017, 12:27 PM EDT