Load a dimension table with a self-referencing foreign key

I’m looking to load a dimension table that will contain a self-referencing key, and I want to understand what the most efficient / effective method would be. Here’s my setup: I have a Message table in my Staging environment that contains two keys, a primary key for the Message and a self-referencing foreign key for […]

How to put all rows in a column to a variable?

I have written a stored procedure as Declare @Split table ( Jurisdiction nvarchar(max) ) Insert into @Split select Jurisdiction from tbLicence where AgentId =@AgentId; Select * from @Split; Declare @products varchar(MAX); Select @products = Jurisdiction from @Split; Select @products; I want to put all the values of column @Split in @products variable. Please note that […]

Interchanging string value position

Is it possible to interchange a number of values of string position? To explain it clearly here: Is it possible for 103414823111 to be altered to something like this 823111103414. To make it detailed: I want to 103414 be placed after 823111 instead of having it before. The cutting of that certain data is done […]

MS SQL Server Agent Jobs sometimes stands

Although the SQL Server Agent service jobs have started then cut and run, sometimes does not work until you restart the jobs related ever again. Why might that be?

T-SQL view is “optimized” but I don't understand why

I’m struggling with some sort of auto-optimization when creating a view in TSQL. The optimization is done both when using the Designer and when using CREATE VIEW. The output is equal, but I don’t understand why it’s done. Can anyone please explain me why this is optimized / why the lower one is better: […] […]

External Process vs. Threads and data processing

I’m working on a mmorpg game server that serves hundreds, sometimes thousands of players simultaneously. Some player actions sent to this server requires database access (sql), for example: when the user selects one of his characters, all data (items, levels, position) associated with this character are retrieved from the sql server even though this application […]

How to set TRUSTWORTHY for every instance

My database uses external C++ libraries for some calculations. As said TRUSTWORTHY indicates whether the instance trusts database. Is it possible to set it for every instance connected to database without doing it manually. ALTER DATABASE db_lib SET TRUSTWORTHY ON

How to query for Select, Group, then Join with date constraint

I am having some issues creating a query to meet a requirement. There are two tables in this form: Names(nameID(PK), name,…); Invoices(nameID(FK), invoiceID, invoiceDate, invoiceTotal,…); I want to display all these columns (Name, invoiceID, invoiceDate, invoiceTotal), with the constraint of having to only show the most recent invoice date. So as such, multiple names can […]

Automatically copy data from one table to another

I need to set up something to copy data from a table in one database to an identical table in another database. I’ve heard about setting up an automatic job in SQL, but I don’t know where to begin. Can someone explain how to do this in SQL Server 2012 using Management Studio?

Convert characters to Chinese/Japanese characters from SQL Server 2005

I’m having an issue where I am pulling some names from a SQL Server 2005 Database and trying to use values from an outputted CSV to create folders in a Windows directory using VBA in Excel but Chinese/Japanese characters are not appearing correctly. In SQL Server the string is stored as ¡è‚¡ä»½æ Instead of 股份 […]

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