Skip to main content

Posts

Showing posts from 2018

Swapping a column value of a table in a single query and not using temp table variable

There are some cases when your guess is right but for the lack of your confidence you have to leave some questions or facts.This doesn't mean that in such cases you need to deliver what you are guessing is good enough to show that you are confident rather not answering is sometime cuts better for those who respect themselves in such a way that "Talk less but always right".But If you are hungry for marks and there is no negative marking then proceed :) Q:Given a table of following structure and data you have to swap('M' to 'F' and 'F' to 'M') column value for column 'SEX' in a single query and you cannot use temp table. ID | SEX | Salary ------------------------ 1 M   45345.00 2 F   75345.00 3 M   64644.00 4 F   5555.00 5 M   34434.00 6 M   84434.00 The query is so simple UPDATE employee SET sex= CASE sex WHEN 'M' THEN 'F'  WHEN 'F' THEN 'M' END That's...

SQL Server(from 2012) FileTable Features some useful SQL Statements

The FileTable feature brings support for the Windows file namespace and compatibility with Windows applications to the file data stored in SQL Server. FileTable lets an application integrate its storage and data management components, and provides integrated SQL Server services - including full-text search and semantic search - over unstructured data and metadata.( FileTable ) Here is sequential SQL statements to enable,alter existing database for FileStream and create FileTable --check current config value EXEC sp_configure filestream_access_level; --reconfig GO EXEC sp_configure 'filestream access level',   2 Go RECONFIGURE GO -- chack file table enabled databases  SELECT DB_NAME(database_id) as [Database Name], non_transacted_access, non_transacted_access_desc ,directory_name FROM sys.database_filestream_options --  Enable a file table in an existing Database ALTER DATABASE TestDB  SET FILESTREAM ( NON_TRANSACTED_ACCESS = FULL, DIRECT...