How to use the DECLARE variables in WHERE CLAUSE

I want to insert and retrieve the inserted row something like this: DECLARE @ultimo int; INSERT INTO pv_mensaje ( reporte , tipo_emisor , emisor , tipo_receptor, receptor, mensaje, registro ) VALUES (1158,’cliente’,6,”,0,’MMMM’ ,GETDATE()) ; SET @ultimo = (SELECT SCOPE_IDENTITY()); SELECT * FROM pv_mensaje WHERE id = (@ultimo) But send me this error: Error report – […]

SQL Server procedure to populate or create tables from views – performance issues

I have written the below code to populate/create tables (t_) from all of the corresponding views (v_) in my database. I converted a previous script from using a cursor to improve running speed. Is there anything else I can do to make this perform better? Any help is appreciated. Please see my code: SET ANSI_NULLS […]

How do I BULK INSERT shared text files from MS OneDrive for Business into SQL-Server?

We are writing a bunch of data (text files, images, MS Excel spreadsheets) to a laptop and we want to share the data among several different team members. The University has MS OneDrive for Business for free so we are using that as our file sharing system (our personal DropBoxes are all full!). We’ve successfully […]

C# SQL Server connection using server Login

I have a problem with connecting to my SQL server. I keep getting “Login failed for user” error messages, but the user I am trying to login as exists as a login on the server. The connection string I use looks like this: Data Source=[server name];Initial Catalog=[database];User ID=[login name];Password=[login password]; Is it because the login […]

SQL Server SSIS Job step history showing twice

There were some T-SQL job steps in SQL Server 2014. I created one SSIS job and inserted as an additional step to be executed only once daily. When I see msdb, it shows it was executed only once but in the history window it is listed twice with the same step number. First it is […]

Use SQL 'like' in Pandas with input()

so I’m using the code below to SELECT columns FROM a certain table in SQL Server. sus_base = pd.read_sql_query(“SELECT screen_name, user_id, text FROM [dbo].[TABLE_ONE]”, con) df1 = pd.read_sql_query(“SELECT screen_name, user_id, text FROM [dbo].[TABLE_ONE] WHERE text like ‘%car%'”, con) df2= pd.read_sql_query(“SELECT screen_name, user_id, text FROM [dbo].[TABLE_ONE] WHERE text like ‘%plane%'”, con) df3= pd.read_sql_query(“SELECT screen_name, user_id, text […]

Need multiple subqueries that return all records in each separately

I need to build a report that will show me each employee (main query), and the date and/or results of each test, with a separate column(s) for each test. I would like the results of my query to look like this: FName LName TB Date TB Result XrayDate ————————————————– Bob Jones 10/1/2016 P 10/1/2016 9/1/2015 […]

extract multiple occurrences with same xpath from xml in sql

I have an xml like this: <root> <parentTag> <child1>p1c1</child1> <child2>p1c2</child2> <child3>p1c3</child3> </parentTag> <parentTag> <child1>p2c1</child1> <child2>p2c2</child2> <child3>p2c3</child3> </parentTag> <parentTag> <child1>p3c1</child1> <child2>p3c2</child2> <child3>p3c3</child3> </parentTag> </root> I want to write a query that returns the columns Child1, Child2 and Child3 with all the values in the tags for child1, child2 and child3. Child1 Child2 Child2 p1c1 p1c2 p1c3 […]

Military to Standard Conversion (Add space between time and AM/PM)

I’m converting military to standard and I was wondering if there is a way to get a space between the time itself and the AM/PM notation when converting (Please don’t mind the variables. The time itself is coming from the user) DECLARE @StartTime TIME(0) = @EncTime; DECLARE @MinutesToAdd INT = CONVERT(VARCHAR(10), @Minutes) DECLARE @SetEndTime VARCHAR(10) […]

The linked server has been created but failed a connection test. Do you want to keep the linked server?

I want to link a SQL Server instance A to other SQL Server Instance B through Linked Server with SQL Server Authentication, but I got below error. I searched it again and again but failed to solve the issue…

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