Mostrando postagens com marcador SQL Server 2008 R2. Mostrar todas as postagens
Mostrando postagens com marcador SQL Server 2008 R2. Mostrar todas as postagens

segunda-feira, 1 de fevereiro de 2016

A different way to create temporary table

Hi!

Today somebody teached me a new way to create temporary table and I found it really cool.

This is a way to create a temporary table cloning only the definition of the original table.

SELECT * INTO #TEMP_CLIENT FROM  CLIENT  WHERE 0 = 1

Isn't it cool?

Good luck!
 

quarta-feira, 6 de janeiro de 2016

You should use sqlcmd.exe using dos prompting to execute large sql files (GREATER THEN 1gb)

Whenever I have to execute a huge file, I use sqlcmd.exe via dos.

My strategy is

STEP 1

Create a specific user for that - something like USR_TOUGH_GUY

OWNED SCHEMAS
db_accessadmin

ROLE MEMBERS
db_accessadmin

STEP 2

Find the executable sqlcmd.exe in the machine where SQL SERVER is installed.

STEP 3

Execute
sqlcmd -S myServer\instanceName -U USR_TOUGH_GUY -P THE_PASSWORD_OF_MR_TOUGH_GUY  -i  C:\yourscript.sql


STEP 4

Disable mr TOUGH_GUY

Final considerations

You could do this using the SQLStudio but it will consume a lot of memory of the machine, if you are, for instance, trying to execute a 4GB file.

Good luck!




terça-feira, 14 de abril de 2015