Sql Server Concurrency and Unique Constraint

I have a table as below AssetResource — AssetResourceId AssetId ResourceNumber ResourceType TrackNumber ChapterNumber I have set Unique Constraint on (AssetId,ResourceNumber, ResourceType). Resource number should be an unique sequence number for each AssetId and ResourceType This table is being updated by multiple processes (same code base) concurrently. Or rows are added for same AssetId and […]

No permission to execute sp_send_dbmail

I have no permission to execute sp_send_dbmail in server and no admin permission to configure that. So, I need an alternative solution. Maybe a script similar to sp_send_dbmail that could be scheduled in the server, sending emails with the query result. I’m not used with Windows, tried to find something in the web, but without […]

T-SQL : If login failed, then sql

Goal: Write a T-SQL statement that checks for login permissions on a linked server db, and then updates a column value based on login result. Sudo-ish code: @Source = linked server connection string while true if exists(select [Something] from [@Source]) update [Table] set [Column] = 1 else update [Table] set [Column] = 0 @Source = […]

Relevant linq query for the SQL

My query initially was select * from Personalization_Mapping The relevant LINQ query was List<Personalization_Mapping> list = _appDbContext.Personalization_Mapping.OrderBy(s => s.ID).ToList(); Now I need the relevant unique columns for which, I changed the SQL to SELECT * FROM (SELECT *, ROW_NUMBER() OVER(PARTITION BY CustomerID ORDER BY ID DESC) rn FROM Personalization_Mapping) a WHERE rn = 1 Could […]

Syntax error in sql server query

I have written this code.. create procedure log_refresh_action (@p_obj_owner varchar(4000) = user, @p_object varchar(4000), @q_new_object varchar(4000), @q_cur_object varchar(4000), @v_num_recs float, @v_start_date datetime, @v_comments varchar(4000) = ‘NA’) as begin set nocount on; I getting an error saying Incorrect Syntax near ‘4000’. Expecting ‘(‘, or SELECT. Please help me with this issue

how to separate and show data from one column?

I have a problem splitting single column values to multiple column values. On this: Name ———— Tom Howard Michael Black Wiliam Cruise Bet Moor I need the output something like this: first_name last_name —————————— Tom Howard Michael Black Wiliam Cruise Bet Moor I have to show data(last_name) from one column(name). Thank you

Reading a large file with stream and inserting to DB NodeJS

I am reading a large file (1mil+ records with many attributes) using NodeJS and module called line-by-line. The reading is in a stream, to avoid an out of memory error. When I reach 50000 records I want to insert them to the DB. I am using node-mssql module for that. As I am quite new […]

Create failed for database 'ToDoList'. (Microsoft.sqlserver.smo)

I am trying to create a database using SQL server Management Studio 2012. But on clicking the create database,i am getting an error: A file activation error occurred. The physical file name ‘ToDoList.mdf’ may be incorrect. Diagnose and correct additional errors, and retry the operation. CREATE DATABASE failed. Some file names listed could not be […]

Enumerate SQL Server services with two different versions of SQL Server present on server

I’m attempting to gather information about the SQL Server services on remote computers, using SMO thru a Powershell script. My code seems to work fine with multiple instances present on the server when they are the same SQL Server version. My problem is that when there are two instances installed that are different versions of […]

Python – DNS lookup from SQL database

I was hoping you could point me in the right direction about a little problem I’m having. I want to create a basic web app that performs DNS queries to validate whether a specific set of DNS records are active or not. The DNS records are all A records and are hosted on an SQL-based […]

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