آموزشی

اجرای Scripts حجیم در SQL

در برخی موارد که ما نیازمند اجرای Scripts در محیط SQL Server Management Studio (SSMS)  هستیم

در صورتی که حجم فایل اسکریپت زیاد باشد با خطای Insufficient memory to continue the execution of the program مواجه میشویم

اجرای Scripts حجیم در SQL

جهت حل این مشکل میتوانیم از SQLCMD  استفاده کنیم

SQLCMD یک رابط کنسول و خط فرمان جهت کار با SQL Server می باشد

ابتدا CMD ویندوز را با دسترسی مدیر(Administator) اجرا کنید

فرمان زیر را با توجه به نام فایل اسکریپت و نام دیتابیس اجرا کنید

SQLCMD -d <database-name> -i filename.sql

 

برای مثال

SQLCMD -d Amirweb -i C:\script.sql

 

با اجرای این فرمان در کنسول، میبینید که شروع به اجرای اسکریپت می‌کند

 

در نهایت بعد از پایان شما دوباره خط فرمان را خواهید دید

اجرای Scripts حجیم در SQL

 

در اینجا لیست پارامتر‌های که می‌توانید در SQLCMD استفاده کنید را قرار می‌دهم

sqlcmd   
   -a packet_size  
   -A (dedicated administrator connection)  
   -b (terminate batch job if there is an error)  
   -c batch_terminator  
   -C (trust the server certificate)  
   -d db_name  
   -e (echo input)  
   -E (use trusted connection)  
   -f codepage | i:codepage[,o:codepage] | o:codepage[,i:codepage] 
   -g (enable column encryption) 
   -G (use Azure Active Directory for authentication)
   -h rows_per_header  
   -H workstation_name  
   -i input_file  
   -I (enable quoted identifiers)  
   -j (Print raw error messages)
   -k[1 | 2] (remove or replace control characters)  
   -K application_intent  
   -l login_timeout  
   -L[c] (list servers, optional clean output)  
   -m error_level  
   -M multisubnet_failover  
   -N (encrypt connection)  
   -o output_file  
   -p[1] (print statistics, optional colon format)  
   -P password  
   -q "cmdline query"  
   -Q "cmdline query" (and exit)  
   -r[0 | 1] (msgs to stderr)  
   -R (use client regional settings)  
   -s col_separator  
   -S [protocol:]server[instance_name][,port]  
   -t query_timeout  
   -u (unicode output file)  
   -U login_id  
   -v var = "value"  
   -V error_severity_level  
   -w column_width  
   -W (remove trailing spaces)  
   -x (disable variable substitution)  
   -X[1] (disable commands, startup script, environment variables, optional exit)  
   -y variable_length_type_display_width  
   -Y fixed_length_type_display_width  
   -z new_password   
   -Z new_password (and exit)  

امیر فدائیان

عاشق تکنولوژی هستم،مشغول برنامه نویسی و همچنین پشتیبانی و نصب سیستم های نظارتی و حفاظتی هست، در اين وبلاگ علاوه بر اينكه دفترچه ياداشتي براي خودم هست ،تجربیات و دانسته‌هام در حوزه نرم‌افزار ،اينترنت ،تلفن همراه و ... را منتشر ميكنم. Programming languages: Delphi, Kotlin, Python, SQL Server

نوشته های مشابه

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *

دکمه بازگشت به بالا