I have a linkedserver that will change. Some procedures call the linked server like this: [10.10.100.50].dbo.SPROCEDURE_EXAMPLE. We have triggers also doing this kind of work. We need to find all places that uses [10.10.100.50] to change it. In SQL Server Management Studio Express, I didn’t find a feature like “find in whole database” in Visual […]
UNPIVOT will not return NULLs, but I need them in a comparison query. I am trying to avoid using ISNULL the following example (Because in the real sql there are over 100 fields.: Select ID, theValue, column_name From (select ID, ISNULL(CAST([TheColumnToCompare] AS VarChar(1000)), ”) as TheColumnToCompare from MyView where The_Date = ’04/30/2009′ ) MA UNPIVOT […]
I have a bunch of Cyrillic-like text in a MSSQL database and need to convert it to Cyrillic in C#. So… Ðàáîòà â ãåðìàíèè should become Работа в германии Any suggestions? I should add that the closest I’ve gotten is ?aaioa a aa?iaiee Here’s the code I’m using: str = Encoding.UTF8.GetString(Encoding.GetEncoding(“Windows-1251”).GetBytes(drCurrent[“myfield”].ToString())); str = Encoding.GetEncoding(1251).GetString(Encoding.Convert(Encoding.UTF8, Encoding.GetEncoding(1251), […]
SQL Server developers consider Cursors a bad practise , except under some circumstances. They believe that Cursors do not use the SQL engine optimally since it is a procedural construct and defeats the Set based concept of RDBMS. However, Oracle developers do not seem to recommend against Cursors. Oracle’s DML statements themselves are implicit cursors. […]
Is it necessary to use # before creating a temporary table in SQL server? Example: SELECT column1, column2, someInt, someVarChar INTO ItemBack1 FROM table2 WHERE table2.ID = 7 For ItemBack1 is it necessary to use the # symbol? If not, then what is the use of # in creating temp tables?
I’m trying to create a simple stored procedure which queries a sys.tables table. CREATE PROCEDURE dbo.test @dbname NVARCHAR(255), @col NVARCHAR(255) AS SET NOCOUNT ON SET XACT_ABORT ON USE @dbname SELECT TOP 100 * FROM sys.tables WHERE name = @col GO This does not seem to work cause I should put GO after USE @dbname but […]
I want to get name of all table of SQL Server database in my C# application. Is It possible? Plz tell me Solution.
I have a view which is selecting rows from a table in a different database. I’d like to grant select access to the view, but not direct access to the base table. The view has a where clause restricting the number of rows. Can I grant select to the view and not the base table, […]
Could you help me frame a query that retrieves the constraints in all the tables, the count of constraints in each table, and also display NULL for tables that do NOT have any constraints. Thx in advance! This is what I have so far: Select SysObjects.[Name] As [Constraint Name] , Tab.[Name] as [Table Name], Col.[Name] […]
Ok, I’ve scoured the web, BOL, various forums and I’m no closer to an answer…hopefully you fine folks can lend a hand… We’ve got a dozen or so SQL Servers (some 2k, some 2005) on a network. I’m using SMO objects in a .NET application to get some standard information. My problem appears to boil […]