Hot answers tagged scripting
Instead of issuing PRINT @tsql;, you can issue EXEC( @tsql );, if I understand what you're asking. If so, I would suggest declaring a preview parameter ( something like DECLARE @Preview BIT = 1; ) and then use an IF to either print or execute. IF ( @Preview = 1 ) BEGIN PRINT @tsql; END ELSE BEGIN EXEC( @tsql ); END;
The spatial index, as with other objects, have their own script <object> as menus and need to be done separately. This can be done to the clipboard and pasted to the query window generated by the script table as command. I can't confirm at the moment, but I suspect that the primary key and other constraints come out in the script table as options ...
Three options: export it to the environment. put it in the script use nzpassword the examples are off the top of my head, I don't have an instance to test it out right now, you might need to tweak them a bit. exporting it to the environment: NZ_PASSWD_ENCRYPTED=29TY20T98= export NZ_PASSWORD=`DecryptFunc $NZ_PASSWD_ENCRYPTED` NzResult=$(nzsql -db ...
Let's say the new default you want is 5: DECLARE @sql NVARCHAR(MAX) = N''; SELECT @sql += N'ALTER TABLE ' + t + ' DROP CONSTRAINT ' + c + '; ALTER TABLE ' + t + ' ADD CONSTRAINT ' + c + ' DEFAULT (5) FOR [project_id];' FROM ( SELECT t = QUOTENAME(s.name) + '.' + QUOTENAME(t.name), c = QUOTENAME(d.name) FROM sys.tables AS t INNER JOIN ...
Only top voted, non community-wiki answers of a minimum length are eligible