-
Few days before i have a requirement to find out the table name which are having a specific column with a specific value throughout the database. for that i build a query which takes <COLUMN NAME> and <VALUE> as parameter For example : A column <Col1> occurs in multiple tables in a...
-
Today one of my friend ask me, can we use Order by clause dynamically ? I said yes, but there are few limitations while using case in order by clause see the below example. This script will return Error: DECLARE @TOP INT = 10, @FLD VARCHAR(20)='AGENT_ID' SELECT TOP(@TOP) * FROM ( SELECT 1 AS...
-
During working with one logic, i got chance to work with PIVOT operation. Sometime we need do require rowdata as column in our custom logic, then we can use some temp table and then populate agreegate data in temp table. But With PIVOT we can do it very easily. Let me prepare small example and explain...
Posted to
sqlideas
by
Paresh Prajapati
on
02-18-2012
Filed under:
Filed under: sql, sql server 2008, sql server 2005, tsql, sql server, ms sql, ms sql server, t-sql, sql server denali, #SQL Server, #sql, sql server 2011, database, sql server general, SQL Scripts, pivot
-
After using some of the ways to delete the files from the particular folder like Delete file using Script Task and File System Task in SSIS. We have seen such methods and used logic to get the files from the loop container and process to delete them and same thing applied for the scripts as well. we...
Posted to
sqlideas
by
Paresh Prajapati
on
02-10-2012
Filed under:
Filed under: sql, sql server, ms sql, ms sql server, #SQL Server, #sql, database, sql server general, SQL Scripts, SSIS, SSDT, retention
-
Earlier we have seen for the Delete file using Script Task and files deletion using File System Task in SSIS. We have directly wrote the logic to get the files and delete from specified folder in the script for the Script Task. For File System Task we have Used Foreach Loop Container and variables to...
Posted to
sqlideas
by
Paresh Prajapati
on
02-04-2012
Filed under:
Filed under: sql, sql server, ms sql, ms sql server, #SQL Server, #sql, database, sql server general, SQL Scripts, SSIS, SSDT, retention
-
Recently when i worked with SQL Server security, i encountered with one error while trying to modify 'SA' account properties. The exception details looks following, Alter failed for Login sa. Cannot set a credential for principal 'sa'. Also you can see the image below for the same. The...
Posted to
sqlideas
by
Paresh Prajapati
on
01-27-2012
Filed under:
Filed under: sql, ms sql, sql server errors, ms sql server, #SQL Server, #sql, database, sql server general, SQL Server Problems, login, Security, Exception, Errors
-
In last post we have seen custom database roles as how can we create it and assign required access to users. We also noticed that we can add multiple members with same role. That was the security with database roles and members comes into the picture. Now here we will study of Application Role. This...
Posted to
sqlideas
by
Paresh Prajapati
on
01-20-2012
Filed under:
Filed under: sql server, ms sql, ms sql server, t-sql, #SQL Server, #sql, database, sql server general, SQL Scripts, login, query, Security
-
Recently while working with database security, I learned database roles as how the each role used. Apart from the server level roles if we need to require to assign access/rights to particular databases level then we need to go through database level roles. Following are the fixed database level roles...
Posted to
sqlideas
by
Paresh Prajapati
on
01-13-2012
Filed under:
Filed under: sql, sql server, ms sql server, #SQL Server, #sql, database, sql server general, Maintenance, SQL Scripts, login, user, query, Security, Role
-
I experienced into one issues for database backups were failed. And this was due to space issues on disk drive. This disk drive is spacific to allocated for the database backups only. The space was eaten by this database backups and this drive contains so many old backups. I have manually deleted all...
Posted to
sqlideas
by
Paresh Prajapati
on
01-07-2012
Filed under:
Filed under: sql, tsql, sql server, ms sql, ms sql server, t-sql, #SQL Server, #sql, database, sql server general, Maintenance, SQL Scripts, backup, query
-
Cross tab result is always required and it is bit complex in case of dynamic column. If column name has to be dynamic then this is the good idea to have the PIVOT Query, for example I have 3 Tables and data like this: First Table ----------------------------------------------------------- IF OBJECT_ID...
-
Earlier we have seen for the files deletion using File System Task in SSIS. We have used it with Foreach Loop Container. Used a variable to hold file names which are passed from earlier stage one by one and then finally used with File System Task to delete it. Now i am going to use Script Task to delete...
Posted to
sqlideas
by
Paresh Prajapati
on
12-30-2011
Filed under:
Filed under: sql, sql server, ms sql, ms sql server, #SQL Server, #sql, database, sql server general, SQL Scripts, SSIS, SSDT
-
We know all the various methods to delete the particular or all files from the specified folder using some of the methods like xp_delete_file , Ole Automation Procedures and with xp_cmdshell command line utility which we used for the old files archive or cleanup purpose. Here i am going to share some...
Posted to
sqlideas
by
Paresh Prajapati
on
12-23-2011
Filed under:
Filed under: sql, tsql, sql server, ms sql, ms sql server, t-sql, #SQL Server, #sql, database, sql server general, SQL Scripts, SSIS
-
We can use this script to show the row data in string. Name ------ RAM SHYAM HARI RITA Name RAM,SHYAM,HARI,RITA --Use the following query DECLARE @strList varchar(100) SELECT @strList = COALESCE(@strList + ', ', '') + CAST(Name AS varchar(5)) FROM TABLE1 SELECT @strList
-
Every DBA has a daily activity review or monitor database backups as these database backups used for the restoration at other place and using for the database restore which used for reporting purpose or used in log shipping purpose. Because database backups are most important factor and first option...
Posted to
sqlideas
by
Paresh Prajapati
on
12-16-2011
Filed under:
Filed under: sql, sql server 2008, sql server 2005, tsql, ms sql, ms sql server, t-sql, #SQL Server, #sql, sql server 2011, database, sql server general, SQL Scripts, backup, statistics
-
When we created a new database it will be created with default isolation level and that is "READ COMMITTED". If some update transactions are running in with table rows under READ COMMITTED isolation level, How can we get data from table in another session while running update transaction? How...
Posted to
sqlideas
by
Paresh Prajapati
on
12-14-2011
Filed under:
Filed under: sql, sql server 2008, sql server 2005, tsql, ms sql, ms sql server, t-sql, sql server denali, #SQL Server, #sql, sql server 2011, database, SQL Scripts, SQL Server Code Named Denali, lock, hint