Tag: sql-server-2012

Rename column returning error

I tried using this procedure to rename badly named columns in SQL Server. The generated statement seems correct: EXEC sp_rename ‘[TBL_TAXREPORTtestxxx].[“InsertedOn”]’, ‘InsertedOn’, ‘COLUMN’ however that gives me the following error: Msg 15248, Level 11, State 1, Procedure sp_rename, Line 266 Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong. Any clue […]

Case statement not correctly matching expected values

I’m trying to generate some randomized data, and I’ve been using newid() to seed functions since it is called once for every row and is guaranteed to return a different result each time. However I’m frequently getting values that are somehow not equal to any integers in the expected range. I’ve tried a few variations, […]

Give permissions to a stored procedure

I have a stored procedure that does a merge into a table. Let’s call it someSchema.UpsertSomeStuff (note that it is not in the dbo schema). Let’s call the table dbo.SomeStuff (note that it is in the dbo schema). When I call the stored procedure with a data reader/data writer user, it works fine. But if […]

Skipping records in subtable

I’m trying to write query, that is selecting few things from 2 tables. Unfortunately I stuck on following problem: in table Person.BusinessEntityAdress You store key to another table with people addresses, but some records got 2 or more keys, and my point is to select just one of those keys, and skip rest. I’m using […]

How to accurately figure percentage of a finite total

I’m in the process of creating a report that will tell end users what percentage of a gridview (the total number of records is a finite number) has been completed in a given month. I have a gridview with records that I’ve imported and users have to go into each record and update a couple […]

concatenate values of one column to single text

my Column is like this: col1 Mary Jack John and i need to get something like this: Mary,Jack,John I did it by using “For XML PATH”, but the problem is that segment not work in SQL server view, is there other way to get concatenation of one column?

Data is splitting into multiple rows while copying from sql server 2012 to excel sheet

SQl Query : select REPLACE(REPLACE(cast(description as nvarchar(max)), CHAR(10), ”), CHAR(13), ”)[description] From EuroRawData where message like ‘%Dewan Sabuj%’ Description column is ntext. Without using replace the result was this : অনেক সময় প্রিয়জনের মোবাইলে টাকা দেয়ার প্রয়োজন হয়। কিন্তু তখন যদি দেখেন ফ্লেক্সিলোড দেওয়া যাচ্ছে না – তাহলে তো সমস্যা । তবে এখন আপনি আপনার […]

How can I group on the SAME table, order by date and limit the number of rows returned?

I would like to return a set that is grouped by ID_F, limited in count within ID_F and sorted by date within ID_F Here is my database setup: CREATE TABLE [dbo].[U]( [ID] [uniqueidentifier] NOT NULL, [Name] [nvarchar](max) NULL, CONSTRAINT [PK_U] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = […]

Why is Linq query setting my Arithabort options to false?

I have code like this: using (var db = new MyDataContext()) { db.ExecuteStoreCommand(“Set Arithabort on”); var q = AFairlyComplexQuery(db); // returns an IQueryable<> var result = q.ToList(); // Line 4 return result; } I was finding that this query was timing out. I ran SQL Profiler and grabbed the SQL and ran it in SSMS, […]

Join Remote database table with my Local database table in SQL Server 2012

I am using SQL Server 2012 Management Studio. I tried to connect to a remote database. I was able to connect successfully but i was restricted to access only for four views. I tried the following steps to join the table with my local table. I tried to use linkedserver but I was un-able to […]

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