how to order list that has date and a word in sql server

case when prefinallist.truckbooked is null then ‘Immediate’ else CAST(prefinallist.previous_date as varchar) END as ETA The list contain either the word Immediate or datetime. How to show immediate on the top and date in acending.

SQL Bulk copy versus Structured Table Insert

Just wondering if there are any performance differences between structured table inserts and bulk copy. Any experience or ideas which might be performant before I start implementing it. I am using Spring.net for the database layer calls. Sql Bulk Insert using (SqlBulkCopy bulkCopy = new SqlBulkCopy(this.connectionstring) { bulkCopy.DestinationTableName = “BulkDataTable”; bulkCopy.WriteToServer(dataTable); } Sql Structured type […]

SQL Server – Join across several tables

Below are the relevant tables info: tgenie Guid | genietypeguid | … and : tgenieType guid | genietype | … I made this query to select all possible entries: select tsearch.description, tcompany.CompanyName, tsearch.CompanyGUID, tgenie.GenieNotes, tGenieType.GenieType from tcompany, tsearch, tGenieType left outer join tGenie on tgenie.GenieTypeGUID = tGenieType.GUID As the result I have this output: description […]

Generating documentation for Power BI

Is there a native solution/application/script for creating documentation in Power BI? I am especially interested in documenting all relationships.

Trying to count the number of distinct values within my defined categories in SQL Server

I am trying to get the number of distinct Business ID’s that fall into each of the categories that I defined in a sub query. I am wondering if this is possible, and if so, how would I go about doing it. So far this code counts the number of businesses and then returns units […]

ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver while deploying google connector for database

I’m deploying google search appliance connector for database(SQL). I’m filling the information in the GSA hostname and other required variable where I have specified the full class name of my JDBC Driver as: com.microsoft.sqlserver.jdbc.SQLServerDriver which is right. I have browsed my library of the JDBC to check that. But after the installation, I am getting […]

SQL dynamic pivot for multiple columns

DECLARE @cols AS NVARCHAR(MAX), @query AS NVARCHAR(MAX) select @cols = STUFF((SELECT ‘,’ + QUOTENAME(Symbol) from Opt FOR XML PATH(”), TYPE ).value(‘.’, ‘NVARCHAR(MAX)’) ,1,1,”) set @query = ‘SELECT Date,’ + @cols + ‘ from ( select Date, Symbol, Price from Opt )x pivot ( max(Price) for Symbol in (‘ + @cols + ‘) ) p’ execute(@query); […]

don`t understand how trigger works

Trigger should react to deleting row from table Suppliers if there is some supplies in the table Supplies from this supplier, trigger should cancel deleting. This code allows to delete both, suppliers with supplies and suppliers without supply: CREATE TRIGGER SuppliersDeleteCondition ON Suppliers FOR DELETE AS IF EXISTS ( SELECT 1 FROM Supplies Ses JOIN […]

Using SQL Server's CONTEXT_INFO for Classic ASP Login Tracking

I’m migrating a classic ASP site to ASP.NET MVC. As part of the migration, we’ve moved the database from MS Access to SQL Server, and have set up basic trigger-level audit logging on the SQL end of things, for good measure. What I want to do is track the currently logged in user of the […]

SQL Server Column level security – is it possible to DENY SELECTs on a column, but, have it available for use in a WHERE clause on that table?

SQL Server 2008, 2012, 2014 Column level security – is it possible to DENY SELECTs on a column, but, have it available for use in the WHERE clause on that table? I don’t want to allow a specific role to read all email addresses, in the “EmailAddress” column, but, I do want that role to […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.