Search Results

Search found 1100 results on 44 pages for 'dbo'.

Page 27/44 | < Previous Page | 23 24 25 26 27 28 29 30 31 32 33 34  | Next Page >

  • convert a sql statement to class?

    - by walter
    Is there a tool or code to convert a sql statement to class? Something like: Dim sqlText = "SELECT CustomerID, Name, Address, City FROM dbo.Customer WHERE CustomerID = 1" Dim obj As New ***SqlStatementTool***(sqlText) obj.GetTables() 'Will Return Tables in sqlText obj.GetWheres() 'Will Return conditions in sqltext obj.GetParameters() 'will return parameters in sqltext

    Read the article

  • T-SQL generated from LINQ to SQL is missing a where clause

    - by Jimmy W
    I have extended some functionality to a DataContext object (called "CodeLookupAccessDataContext") such that the object exposes some methods to return results of LINQ to SQL queries. Here are the methods I have defined: public List<CompositeSIDMap> lookupCompositeSIDMap(int regionId, int marketId) { var sidGroupId = CompositeSIDGroupMaps.Where(x => x.RegionID.Equals(regionId) && x.MarketID.Equals(marketId)) .Select(x => x.CompositeSIDGroup); IEnumerator<int> sidGroupIdEnum = sidGroupId.GetEnumerator(); if (sidGroupIdEnum.MoveNext()) return lookupCodeInfo<CompositeSIDMap, CompositeSIDMap>(x => x.CompositeSIDGroup.Equals(sidGroupIdEnum.Current), x => x); else return null; } private List<TResult> lookupCodeInfo<T, TResult>(Func<T, bool> compLambda, Func<T, TResult> selectLambda) where T : class { System.Data.Linq.Table<T> dataTable = this.GetTable<T>(); var codeQueryResult = dataTable.Where(compLambda) .Select(selectLambda); List<TResult> codeList = new List<TResult>(); foreach (TResult row in codeQueryResult) codeList.Add(row); return codeList; } CompositeSIDGroupMap and CompositeSIDMap are both tables in our database that are represented as objects in my DataContext object. I wrote the following code to call these methods and display the T-SQL generated after calling these methods: using (CodeLookupAccessDataContext codeLookup = new CodeLookupAccessDataContext()) { codeLookup.Log = Console.Out; List<CompositeSIDMap> compList = codeLookup.lookupCompositeSIDMap(5, 3); } I got the following results in my log after invoking this code: SELECT [t0].[CompositeSIDGroup] FROM [dbo].[CompositeSIDGroupMap] AS [t0] WHERE ([t0].[RegionID] = @p0) AND ([t0].[MarketID] = @p1) -- @p0: Input Int (Size = 0; Prec = 0; Scale = 0) [5] -- @p1: Input Int (Size = 0; Prec = 0; Scale = 0) [3] -- Context: SqlProvider(Sql2005) Model: AttributedMetaModel Build: 3.5.30729.1 SELECT [t0].[PK_CSM], [t0].[CompositeSIDGroup], [t0].[InputSID], [t0].[TargetSID], [t0].[StartOffset], [t0].[EndOffset], [t0].[Scale] FROM [dbo].[CompositeSIDMap] AS [t0] -- Context: SqlProvider(Sql2005) Model: AttributedMetaModel Build: 3.5.30729.1 The first T-SQL statement contains a where clause as specified and returns one column as expected. However, the second statement is missing a where clause and returns all columns, even though I did specify which rows I wanted to view and which columns were of interest. Why is the second T-SQL statement generated the way it is, and what should I do to ensure that I filter out the data according to specifications via the T-SQL? Also note that I would prefer to keep lookupCodeInfo() and especially am interested in keeping it enabled to accept lambda functions for specifying which rows/columns to return.

    Read the article

  • Datatype Conversion

    - by user87
    I am trying to execute the following Query select distinct pincode as Pincode,CAST(Date_val as DATE) as Date, SUM(cast(megh_38 as int)) as 'Postage Realized in Cash', SUM(cast(megh_39 as int)) as 'MO Commission', from dbo.arrow_dtp_upg group by pincode,Date_Val but I am getting an error "Conversion failed when converting the nvarchar value '82.25' to data type int." Am I using a wrong data type?

    Read the article

  • Entity Data Model Wizzard not creating tables in EDMX file

    - by Shawn
    I'm trying the database first approach by creating an ADO.NET Entity Data Model using the Wizard with the Adventureworks2012 DB. Testing DB connection works, and the connection string is added to the App.Config. I'm selecting all the tables except the ones marked as (dbo) AWBuildVersion, DatabaseLog, and ErrorLog. When the Wizard finishes the .edmx file is blank, and if I view the file in XML view the EntityContainer is empty. I'm using VS 2010 & .NET Framework 4.0

    Read the article

  • whats best practice for Log Truncation in SQL Server?

    - by kacalapy
    i have a production DB in SQL server and wanted to put the final touches after the functionality is completed. prior to shipping it out i want to make sure i have some clean up in the SQL server DB and truncate and shrink log files? can i have a nightly job run to truncate logs and shrink files? this is what i have so far: ALTER proc [dbo].[UTIL_ShrinkDB_TruncateLog] as -- exec sp_helpfile BACKUP LOG PMIS WITH TRUNCATE_ONLY DBCC SHRINKFILE (PMIS, 1) DBCC SHRINKFILE (PMIS, 1)

    Read the article

  • Microsoft SQL Server 2005 Function, passing list of start and end times

    - by Kevin
    I'd like to do had a dynamic number of one start/end time pairs passed to a function as an input parameter. The function would then use the list instead of just one start, and one end time in a select statement. CREATE FUNCTION [dbo].[GetData] ( @StartTime datetime, @EndTime datetime ) RETURNS int AS BEGIN SELECT @EndTime = CASE WHEN @EndTime > CURRENT_TIMESTAMP THEN CURRENT_TIMESTAMP ELSE @EndTime END DECLARE @TempStates TABLE (StartTime datetime NOT NULL , EndTime datetime NOT NULL , StateIdentity int NOT NULL ) INSERT INTO @TempStates SELECT StartTime , EndTime , StateIdentity FROM State WHERE StartTime <= @EndTime AND EndTime >= @StartTime RETURN 0 END

    Read the article

  • How to update a single table using trigger in MS SQL 2008

    - by Yakob-Jack
    I have a table PeroidicDeduction and the fields are ID(auto-increment),TotalDeduction(e.g.it can be loan),Paid(on which the deduction for each month),RemainingAmount, What I want is when every time I insert or update the table---RemainingAmount will get the value of TotalDeduction-SUM(Paid)....and writ the following trigger...but dosen't work for me CREATE TRIGGER dbo.UpdatePD ON PeroidicDedcution AFTER INSERT,UPDATE AS BEGIN UPDATE PeroidicDedcution SET REmaininAmoubnt=(SELECT TotalDeduction-(SELECT SUM(Paid) FROM PeroidicDeduction) FROM PeroidicDeduction) END NOTE: it is on a Single table

    Read the article

  • How to get last full MS SQL Server error message?

    - by JohnM2
    I am aware of: SELECT @@ERROR but it will give me only an ERROR CODE (a number) and I need a full text message like: Cannot insert duplicate key row in object 'dbo.TABLE_NAME' with unique index 'IX_ID_unique'. The statement has been terminated. How can I do that in MS Sql Server 2005 ?

    Read the article

  • Error while conversion of string to datetime

    - by aswathi
    The conversion of a char data type to a DateTime data type resulted in an out-of-range DateTime value. The statement has been terminated. Please give me most possible answers ALTER PROCEDURE [dbo].[attendance_updatebyemployee_id] @Employee_id int, @AtDate datetime, @FNLogged bit, @ANLogged bit, @LogTime varchar(10), @LogOuttime varchar(10) AS BEGIN SET NOCOUNT ON; update Mst_Attendance set FNLogged=@FNLogged, ANLogged=@ANLogged,LogTime=@LogTime,LogOuttime=@LogOuttime where EmployeeId=@Employee_id and Atdate= @AtDate END

    Read the article

  • B-trees, databases, sequential inputs, and speed.

    - by IanC
    I know from experience that b-trees have awful performance when data is added to them sequentially (regardless of the direction). However, when data is added randomly, best performance is obtained. This is easy to demonstrate with the likes of an RB-Tree. Sequential writes cause a maximum number of tree balances to be performed. I know very few databases use binary trees, but rather used n-order balanced trees. I logically assume they suffer a similar fate to binary trees when it comes to sequential inputs. This sparked my curiosity. If this is so, then one could deduce that writing sequential IDs (such as in IDENTITY(1,1)) would cause multiple re-balances of the tree to occur. I have seen many posts argue against GUIDs as "these will cause random writes". I never use GUIDs, but it struck me that this "bad" point was in fact a good point. So I decided to test it. Here is my code: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[T1]( [ID] [int] NOT NULL CONSTRAINT [T1_1] PRIMARY KEY CLUSTERED ([ID] ASC) ) GO CREATE TABLE [dbo].[T2]( [ID] [uniqueidentifier] NOT NULL CONSTRAINT [T2_1] PRIMARY KEY CLUSTERED ([ID] ASC) ) GO declare @i int, @t1 datetime, @t2 datetime, @t3 datetime, @c char(300) set @t1 = GETDATE() set @i = 1 while @i < 2000 begin insert into T2 values (NEWID(), @c) set @i = @i + 1 end set @t2 = GETDATE() WAITFOR delay '0:0:10' set @t3 = GETDATE() set @i = 1 while @i < 2000 begin insert into T1 values (@i, @c) set @i = @i + 1 end select DATEDIFF(ms, @t1, @t2) AS [Int], DATEDIFF(ms, @t3, getdate()) AS [GUID] drop table T1 drop table T2 Note that I am not subtracting any time for the creation of the GUID nor for the considerably extra size of the row. The results on my machine were as follows: Int: 17,340 ms GUID: 6,746 ms This means that in this test, random inserts of 16 bytes was almost 3 times faster than sequential inserts of 4 bytes. Would anyone like to comment on this? Ps. I get that this isn't a question. It's an invite to discussion, and that is relevant to learning optimum programming.

    Read the article

  • Linq to Sql: Generic Stored Procedures

    - by Eric
    Hello everyone, I am using Linq-to-Sql for a C# application and am currently working on some stored procedures. The application is for a newspaper, and a sample stored procedure is the following: ALTER PROCEDURE dbo.Articles_GetArticlesByPublication @publicationDate date AS SELECT * FROM Articles WHERE Articles.PublicationDate=@publicationDate Anyway, this query gets all of the articles where the publication date is equal to the argument (publicationDate). How can I alter this so that the argument can handle multiple publication dates? Also, I'd prefer not to use "BETWEEN," rather, I want to pick and choose dates.

    Read the article

  • SQL 2008 HierarchyID - Select X descendants down

    - by NTulip
    How can I query a table which has a column of data type HIERARCHYID and get a list of descendants X levels deep under an employee? Here is the current structure: CREATE TABLE [dbo].[Employees]( [NodeId] [hierarchyid] NOT NULL, [EmployeeId] [int] IDENTITY(1,1) NOT NULL, [FirstName] [varchar](120) NULL, [MiddleInitial] [varchar](1) NULL, [LastName] [varchar](120) NULL, [DepartmentId] [int] NULL, [Title] [varchar](120) NULL, [PhoneNumber] [varchar](20) NULL, [IM] [varchar](120) NULL, [Photo] [varbinary](max) NULL, [Bio] [varchar](400) NULL, [Active] [bit] NULL, [ManagerId] [int] NULL )

    Read the article

  • Update just one field from backup

    - by justSteve
    I'm looking to restore one field from a backup and can't find the syntax for an update statement that can look at 2 different catalogs. Seems like it should be something fairly close to: update users set idUserCompany = (select idUserCompany from .myBackup.dbo.users uT) where uT.idUser = idUser

    Read the article

  • Mssql varchar to datetime

    - by Dezigo
    I have a field varchar(14) = 20090226115644 I need convert it to - 2009-02-26 11:56:44 (datetime format) My idea. use cast and convert.. but I allways have errors. Conversion failed when converting datetime from character string. I made this, but don`t like it.. SELECT SUBSTRING(move,1,4) + '-' + SUBSTRING(move,5,2) + '-' + SUBSTRING(move,7,2) + ' ' + SUBSTRING(move,9,2) + ':' + SUBSTRING(move,11,2) + ':'+SUBSTRING(move,13,2) as new -- FROM [Test].[dbo].[container_events] where move IS not null Result :2009-02-26 11:56:44

    Read the article

  • Use database dynamically

    - by Redi
    This execution it is giving me an error! Any hints of what am I missing? declare @dbname varchar(500) set @dbname='master' Exec (' Use ' + @dbname + ' go create PROCEDURE [dbo].[krijo_database] @dbname nvarchar(2000), @Direktoria varchar(4000) AS BEGIN declare @stringu nvarchar(100) set @stringu = ''CREATE DATABASE '' + @dbname exec (@stringu) End ')

    Read the article

  • LINQ to SQL table naming

    - by Ivo
    I am using VS2010 and C# When I map/select my database tables with LINQ to SQL I have to option to change the "member" propery, but when i delete the table (because I changed something in the schema for example) and add it again the member value gets "reset". Is it possible to set/override this member programmaticly, so that I dont have to change it by hand everytime I mean the member option of '<'Table Name="dbo.table1" Member="table1"

    Read the article

  • Stored Procedure IDENTITY_INSERT

    - by Jacob
    I'm recently change my data table, I remove column and add a new column that define as identity = True and identity seed = 1, identity increment = 1. When i tried to insert data to this table by STORE PROCEDURE i get this exception: An explicit value for the identity column in table 'AirConditioner' can only be specified when a column list is used and IDENTITY_INSERT is ON. I saw that i need to add this lines: SET IDENTITY_INSERT [dbo].[AirConditioner] ON and finally OFF I added and its still throw an exception... My store procedure is attached as a picture

    Read the article

  • Select into from one sql server into another?

    - by blasto
    I want to select data from one table (T1, in DB1) in one server (Data.Old.S1) into data in another table (T2, in DB2) in another server (Data.Latest.S2). How can I do this ? Please note the way the servers are named. The query should take care of that too. That is, SQL server should not be confused about fully qualified table names. For example - this could confuse SQL server - Data.Old.S1.DB1.dbo.T1.

    Read the article

  • Does an XML schema or DTD exist for PerformancePoint's Xml Metadata?

    - by Athens
    I wrote several XQuery statements to shred existing KPI and Dashboard metadata but I would like to validate my queries by reviewing the corresponding Xml Schema or DTD if it exists. I searched online but could not find what i was looking for. The metadata is stored in Performance Point's back end Sql Server database in the dbo.FCObjects table's SerializedXml column.

    Read the article

  • How to get size of file uploaded to SQL-Server?

    - by MadBoy
    Is there a way to tell how to get a file size that is uploaded to database? SELECT [ID] ,[File] FROM [dbo].[Reports] I would like to be able to tell user the size of File which is VarBinary(max) field in MS SQL 2005/2008. How to do that? Maybe the only way to do is to create another column and when inserting file i should also insert it's size in additional column?

    Read the article

  • Trace Flag 1211 Not Working - SQL Server 2008 R2

    - by psam
    During a SSIS load, when an employee table is getting updated, locking comes into effect. However, have disabled lock escalation on the table using the following statements: ALTER TABLE dbo.Employee SET (LOCK_ESCALATION = DISABLE) DBCC TRACEON (1211,-1) However, the table (object) does get locked and is held for almost an hour. The total no. of updates (insert, update, delete statements) are approx 200,000

    Read the article

< Previous Page | 23 24 25 26 27 28 29 30 31 32 33 34  | Next Page >