Category "sql-server"

Using SQL to join tables with a junction table

I am trying to output data from 2 different tables in my database which are joined by a junction table. Table 1: musician Columns: musicianID, surname, fName

Tabbed Reports in SSRS

I have been working on reports in Sql Server Reporting services and I am trying to create a tabbed report. I wish to have a main report which read in parameter

SSIS - Connection Manager Work Offline is grayed out

I am trying to debug an SSIS package locally, but for some reason the connection manager is offline and it can't be changed. Have anyone faced this issue before

Cannot get Linked Servers to work in Sql Azure

We are using a trial version of Azure. We are trying to perform cross server queries from our SQL Server 2012 in-house. We seem to have our local 2012 linked wi

Fully dynamic Stored SQL Procedures?

Is it possible to have fully dynamic SQL Stored procedures? I've read up on dynamic SQL for the past few hours but couldn't find the "fully dynamic" solution th

Mask the last 4 digit in an account number

I need to do an Select on a table that has many records to mask the Account Number. Example AccNumber : 123400012341234 Output result should look like 1234000

SQL Server convert select a column and convert it to a string

Is it possible to write a statement that selects a column from a table and converts the results to a string? Ideally I would want to have comma separated value

vbscript - SQL Windows Authentication - different user

I want to read data from an SQL Database in my VBS Script. My problem: I need to logon with Windows Authentication and not with an SQL Account. But I cannot use

How to create identity column when importing data from Excel into MS SQL Server (with Import and Export Wizard)?

I need to import great amount of data from excel into MS SQL Server, using the Import/ Export Wizard. Then I'll continue importing more data into the same table

How to enable/disable trigger in procedure?

I have two databases (firstDB and secondDB) on MS SQL server. There is procedure [dbo].[MaintaineIndexes] in firstDB and DatabaseEventsTrigger in secondDB. I wa

How to cast a datetime format to date as string in SQL Server

I am struggling to find a solution for the below issue. date1 = 31-08-2017 12:10:00 I want to cast it as string and need to take date (31-08-2017) alone. Th

Can't select column name from Eloquence database that has a forward slash in it (from a linked server in SQL Server)

My SQL Server instance has a linked server to an Eloquence database. I need to select data from one of the tables in the Eloquence database, but I need to do i

Synapse external table "Unauthorized"

I have created an external table in Azure Synapse from a parquet file stored in an ADLS Gen2 container. I have used the following three queries to create the da

Two foreign keys reference one table - ON UPDATE SET NULL doesn't work

I've got two foreign keys in a table. Let's assume that table is called News and has foreign keys updatedById and createdById, both of which point to userId in

Issues with SQL Server and PYODBC

I'm getting an error at this statement: cursor.execute("SELECT * FROM dbo.User") Error: pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driv

SQL group by: select value where another column has its min/max

I want to group by one column, get both min and max of a second column, and (this is the tricky part!) get the value from a third column where the second column

SQL placement join with student, friend, package

Issue: You are given three tables: Students, Friends and Packages. Students contains two columns: ID and Name. Friends contains two columns: ID and Friend_ID

My SQL query runs perfectly, but when I add the CTE function, I get an error

My SQL query runs perfectly, but when I add the CTE function, I get an error Please check this code and let me know what's wrong with the CTE: WITH Consumption_

Need to retrieve images (Varbinary MAX) from SQL Server 2014 to Xamarin by using C#

I am new to the Xamarin platform, I have a local hosted database in SQL Server 2014 using php (with aid of XAMP server) and the table name ItemProductsDB and sa

SQL Transpose Rows to undefined number of columns

I have a table containing graduate ids, degree titles and graduation years. The table can contain any number of rows for each graduate. I would like to create