Conversion failed when converting the nvarchar value 'CIS100 ' to data type int

Can somebody help me? I’m trying to run a count command so it counts all of the students that are in each class number so I’m running this command. Although I’m getting this error. Conversion failed when converting the nvarchar value ‘CIS100 ‘ to data type int Here’s my SQL Query USE RMUDB GO SELECt […]

Ensuring table is empty before data migration in order to not add duplicates

When performing a data migration in tsql, how do we make sure the table is empty before we bring over the data in order to not add duplicates. For example to see if a table exists we use: if exists(select * from sys.objects where name=’table name’) drop table table name go What do we use […]

SSIS-Calling java service using Script Task

I am trying to call a java base web service method writing following code in script task’s entry point method. Following code get executing properly if i call from console application but while calling from SSIS control flow, upto message box 1 it get executed properly but on executing webRequest.GetResponse() what happen dont know neither […]

Run a SQL subquery based on results of the main query

Is there a better way to do this? The SQL Server 2008 R2 table-valued function below runs a query to determine how many records there are that match a specific criteria and then performs another query based on the results of the first query. Is this the right approach? Or is there a better way […]

Only filter my time in SQL Server where clause

I am new to SQL and Programming in general. I have a datetime field which I want to use to filter my results but only on the time portion. For example I need to run a report from 2pm yesterday to 7am current day. I cannot hard code the dates because this report needs to […]

Sql Partitioning

I have Sql Table data and i need to filter only the Consecutive dates blocks as i highlighted on image below.. . and i need to add custom rates for each row on that selected blocks(this rate can display with separate column on out put).If there is more than 6 rows captured then $200 apply […]

Clustered Index improvemens for particular queries

I found a table that looks like this: CREATE TABLE [dbo].Table1 ( id INT primary key IDENTITY (1, 1), [idUser] INT NOT NULL , [Amount] INT NOT NULL , [Attempts] INT NOT NULL , [date] [datetime] NOT NULL , [SUM_Amount] INT NOT NULL ) ON [PRIMARY] This table is created and populated with aggregated data […]

Fatal error: Call to undefined function sqlsrv_connect() in C:\wamp\www\last\connect.php

I am simply trying to connect my php to an microsoft sql server 2005. However, I’m getting this error: Fatal error: Call to undefined function sqlsrv_connect() in C:\wamp\www\last\connect.php My code is simply: <?php $serverName = “OurIPAddress”; //serverName\instanceName, portNumber (default is 1433) $connectionInfo = array( “Database”=>”Thenameofourdatabase”, “UID”=>”OurID”, “PWD”=>”Ourpassword”); $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn ) […]

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 […]

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