Manage substring with empty records

I have two field in a table representing the firstname and lastname, and must put together in a single field in a view. While doing so I must put all in small caps. SELECT /* NAME*/ COALESCE(UPPER(SUBSTRING(LastName, 1, 1)), ”) + COALESCE(LOWER(SUBSTRING(LastName, 2, LEN(LastName)-1)), ”) + ‘ ‘ + COALESCE(UPPER(SUBSTRING(FirstName, 1, 1)), ”) + COALESCE(LOWER(SUBSTRING(FirstName, […]

Restore SQL Server database to different server with non sysadmin user

I’m trying to restore a database from a backup into a different server using an user that is not sysadmin (with dbcreator server role). According to this: http://technet.microsoft.com/en-us/library/ms190436(v=sql.105).aspx the user that restores the database is the dbOwner. Using a sysadmin user I can see in the database properties that the user that restored the database […]

Retrieving User activity from mssql for particular user else for all user

Create PROCEDURE [dbo].[sp_ReadUserActivity] @fromdate datetime, @todate datetime, @EmployeeID int, @Activity varchar(255) AS BEGIN Begin Transaction Select * from dbo.ActivityLog where ActivityDate<=@fromdate and ActivityDate>=@todate commit transaction END I want these things, If data required for all users, pass Activity as “All” else pass EmployeeID If data required for all activities, pass Activity as “All” else pass […]

asp.net mvc web application error “cannot attach database … as … ”

I am new to ASP.NET MVC and I am developing an ASP.NET web application named Spotlight but keep getting this error. I have Visual Studio 2013 and I can’t seem to find the database at all in the Server Explorer. I also checked the App_Data folder and it is completely empty. Would someone help me […]

SQL select latest row from multiple inner join with Optional parameters SP

i have the following tables : Locations _________________ Location_ID, TrackingVehicle_ID, GPS_Time, Longitude, Latitude, Speed, Angle, LocationStatus_No, IgnitionStatus_No, Address, Distance, Message_Type_No, StreetSpeed, Vehicle_ID, Driver_ID. Vehicles ___________ Vehicle_ID, Company_ID, PlateNumber, VehicleType_No, VehicleSubType_No, Status_ID. TrackingVehicles ___________________ TrackingVehicle_ID, Fleet_ID, Vehicle_ID, Driver_ID, MaxSpeed, Vehicle_SN, NavDevice_ID, Latest_LocationID, Latest_GPS_Time. VehicleFences _______________ VehicleFecne_ID, GeoFence_ID, Vehicle_ID. i want to return the vehicles for a […]

How to debug/troubleshoot SQL Server stored proc type error with many parameters?

I’ve looked around quite a bit. The questions I’ve seen here that involve the SSMS 2008+ debug tool have not been helpful to me because executing the proc fails as soon as you step into it. A type mismatch that can’t be implicitly converted will throw an error, and you won’t know which parameter was […]

ssms error while saving .sql file… “ The operation cannot be completed”

I am using sql server management studio 2008. I have a .sql file of about 45 MB. When I make some change in this and try to save using Save Button or press Ctrl+S…. error occurs as: The operation cannot be completed But when I installed SSMS, it was working properly, but after that 45 […]

Bulk Insert from sqlcmd not firing trigger

I’m using sqlcmd in a batch file to do weekly imports. sqlcmd -U xxxx -P xxxx -i E:\data\importtc.sql The command is executing, bulk insert [xxxx].[dbo].[Stage] from ‘E:\Acct\timecards\timecard.txt’ with (fieldterminator = ‘,’, rowterminator = ‘\n’, FIRE_TRIGGERS) go From inside the SQL Server Management Studio, this works fine. However when I exec it from SQLCMD it won’t […]

Executing s. procedure from linked server, filling table

OLE DB provider “SQLNCLI11” for linked server “server1” returned message “The partner transaction manager has disabled its support for remote/network transactions.”. Msg 7391, Level 16, State 2, Procedure sp2, Line 12 The operation could not be performed because OLE DB provider “SQLNCLI11” for linked server “server1” was unable to begin a distributed transaction. and procedure […]

get data from 1column and split in to two using based using table join and column filter in sql

I have 3 tables: wn_synset(synset_id decimal, w_num decimal, word varchar(255), ss_type char) This table contains word List in word column. wn_gloss(synset_id decimal, gloss varchar(255) This table contains meaning(wn_gloss.gloss) of word List of wn_synset table, related with its synset_id column. wn_antony (synset_id_1 decimal, w_num_1 decimal, synset_id_2 decimal, w_num_2 decimal) This table contains synset_id and w_num of […]

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