Search Results

Search found 28024 results on 1121 pages for 'sql 2014'.

Page 111/1121 | < Previous Page | 107 108 109 110 111 112 113 114 115 116 117 118  | Next Page >

  • Why is using OPENQUERY on a local server bad?

    - by Ziplin
    I'm writing a script that is supposed to run around a bunch of servers and select a bunch of data out of them, including the local server. The SQL needed to SELECT the data I need is pretty complicated, so I'm writing sort of an ad-hoc view, and using an OPENQUERY statement to get the data, so ultimately I end up looping over a statement like this: exec('INSERT INTO tabl SELECT * FROM OPENQUERY(@Server, @AdHocView)') However, I've heard that using OPENQUERY on the local server is frowned upon. Could someone elaborate as to why?

    Read the article

  • Linq-to-SQL: How to perform a count on a sub-select

    - by Peter Bridger
    I'm still trying to get my head round how to use LINQ-to-SQL correctly, rather than just writing my own sprocs. In the code belong a userId is passed into the method, then LINQ uses this to get all rows from the GroupTable tables matching the userId. The primary key of the GroupUser table is GroupUserId, which is a foreign key in the Group table. /// <summary> /// Return summary details about the groups a user belongs to /// </summary> /// <param name="userId"></param> /// <returns></returns> public List<Group> GroupsForUser(int userId) { DataAccess.KINv2DataContext db = new DataAccess.KINv2DataContext(); List<Group> groups = new List<Group>(); groups = (from g in db.Groups join gu in db.GroupUsers on g.GroupId equals gu.GroupId where g.Active == true && gu.UserId == userId select new Group { Name = g.Name, CreatedOn = g.CreatedOn }).ToList<Group>(); return groups; } } This works fine, but I'd also like to return the total number of Users who are in a group and also the total number of Contacts that fall under ownership of the group. Pseudo code ahoy! /// <summary> /// Return summary details about the groups a user belongs to /// </summary> /// <param name="userId"></param> /// <returns></returns> public List<Group> GroupsForUser(int userId) { DataAccess.KINv2DataContext db = new DataAccess.KINv2DataContext(); List<Group> groups = new List<Group>(); groups = (from g in db.Groups join gu in db.GroupUsers on g.GroupId equals gu.GroupId where g.Active == true && gu.UserId == userId select new Group { Name = g.Name, CreatedOn = g.CreatedOn, // ### This is the SQL I would write to get the data I want ### MemberCount = ( SELECT COUNT(*) FROM GroupUser AS GU WHERE GU.GroupId = g.GroupId ), ContactCount = ( SELECT COUNT(*) FROM Contact AS C WHERE C.OwnerGroupId = g.GroupId ) // ### End of extra code ### }).ToList<Group>(); return groups; } }

    Read the article

  • MS-Access to SQL Server 2000 problem with datetime

    - by 0plus1
    I'm trying to transfer some data from Access to SQL Server 2000 (there are no other way to do this sadly), I'm using Access to mssql to do the job. The program fails everytime it finds a datetime in this fashion: 03/07/2009 10.17.00 While it imports date like this: 29/12/2008 I don't understand where this problem come from so I ask you for your help. Thank you very much.

    Read the article

  • Inverse of COALESCE

    - by ercan
    Hi all, is there a function in SQL Server 2005 that returns NULL if any of the arguments (of any type) is NULL, which would saves me from writing IF a IS NULL OR b IS NULL OR c IS NULL ....

    Read the article

  • SQL Random number not working

    - by JMSA
    declare @fieldForceCounter as int declare @SaleDate as dateTime declare @RandomNoSeed as decimal set @fieldForceCounter = 1 set @SaleDate = '1 Jan 2009' set @RandomNoSeed = 0.0 WHILE @fieldForceCounter <= 3 BEGIN while @SaleDate <= '1 Dec 2009' begin INSERT INTO MonthlySales(FFCode, SaleDate, SaleValue) VALUES(@fieldForceCounter, @SaleDate, RAND(@RandomNoSeed)) set @saleDate = @saleDate + 1 set @RandomNoSeed = Rand(@RandomNoSeed) + 1 end set @SaleDate = '1 Jan 2009' set @fieldForceCounter = @fieldForceCounter + 1 END GO This T-SQL command was supposed to insert random values in the 'SaleValue'-column in the 'MonthlySales'-table. But it is inserting '1' every time . What can be the problem?

    Read the article

  • Recursive t-sql query

    - by stackoverflowuser
    Hi I have a table as shown below. ID ParentID Node Name Node Type ------------------------------------------------------------------ 525 524 Root Area Level 1 526 525 C Area Level 2 527 525 A Area Level 2 528 525 D Area Level 2 671 525 E Area Level 2 660 527 B Area Level 3 672 671 F Area Level 3 How can i write a recursive t-sql query to generate below output? Output ("Root" node not required in the output): Node ID ----------------------- A 527 A/B 660 C 526 D 528 E 671 E/F 672 Thanks

    Read the article

  • Convert a MSSQL database to MYSQL database

    - by soldieraman
    Alright so I want to convert an already exist MSSQL database (2005) to a MYSQL database. There is nothing extraordinary to be done The only things I need to achieve is Recreate the tables Transfer data Relationships would be nice but not necessary No views, no sprocs, no functions. Any easy way to do this. Also do you know of any DST (Database Synchronization Tool) which would let me do MSSQL to MYSQL MYSQL to MYSQL MSSQL to MSSQL (I know there is SQL Delta for this)

    Read the article

  • Command line or library "compare tables" utility for SQL server with comprehensive diff output to a

    - by MicMit
    I can't find anything like that. Commercial or free ( XSQL Lite is suitable for my case and ) tools show diffs in grids with possibility to export to CSV. Also they generate sync SQL scripts when run from command line. What I need is an output as a comprehensive report ( XML , HTML ) suitable for parsing so that I would be able to show similar diff grid in my application ( updated old/new values for each column , added - all values for row , deleted - all values for row and etc... ) .

    Read the article

  • T-SQL String Functions: difference between using Left/Right and Substring and strange behaviour

    - by TheObserver
    I am using SQL Server 2008 & 2005 (Express). I'm trying to extract part of an alpha numeric string from a varchar field. RIGHT(str_field,3) yields null values but substring(str_field, len(str_field)-2, len(str_field)) gives the right value. left(str_field,7) gives the expected values. What gives? I would have thought that RIGHT(str_field,3) and substring(str_field, len(str_field)-2, len(str_field)) are equivalent expressions.

    Read the article

  • Microsoft SQL Count problem

    - by Matt
    Hey smarties. I'm having trouble with the following SQL statement. I know that I can't do a GROUP BY on the OnlineStatus column, and it makes sense because it's a function call, not an actual column in my table. How would I modify this so that I can get a count of how many users are online? SELECT CASE dbo.fnGetWebUserOnlineStatus(W.Id) WHEN 1 THEN 'Online' WHEN 2 THEN 'Ingame' ELSE 'Offline' END AS OnlineStatus FROM dbo.WebUsers W WHERE W.[Status]=1 GROUP BY OnlineStatus

    Read the article

  • Is there an equivalent of "OPTION(RECOMPILE)" or "WITH RECOMPILE" for an entire connection?

    - by kamens
    I'm curious. Is there any way to prevent SQL query execution plans from being cached for an entire connection's duration? Can I run a command that basically says, "use OPTION(RECOMPILE) for all subsequent commands until I tell you to stop doing so?" I'm acutely aware of all the performance trade-offs here, and I know this is not a step to be taken lightly. However, I'm in a unique situation where this behavior may be advantageous.

    Read the article

  • Dynamic SQL to query an Adventureworks table

    - by salvationishere
    I am trying to see a list of tables from Adventureworks DB from "Person" schema in Sql Server 2008. I developed teh following SP, but after running it as follows it gives me error "Incorrect syntax near ')'". Do you know how I can revise this SP or exec statement? CREATE PROCEDURE [getTableNames] @SchemaName VARCHAR(50) AS BEGIN SET NOCOUNT ON; SET @SchemaName = 'PERSON' DECLARE @cmd AS VARCHAR(max) SET @SchemaName = RTRIM(@SchemaName) SET @cmd = N'SELECT TABLE_NAME ' + 'FROM information_schema.Tables ' + 'WHERE TABLE_TYPE = ''BASE TABLE'' AND TABLE_SCHEMA = @SchemaName' END exec sp_executesql getTableNames, N'@SchemaName NVARCHAR(50), @SchemaName'

    Read the article

  • Changing default logical filename in SQL 2005

    - by Andrew
    I have a issue about creating databases in SQL 2005. I want to be able to change the default logical filename for the mdf file. At the moment the log logical filename ends in _log by default. I want the data logical filename to automatically end with _data for consistency. Is there a way i can set this? Andrew

    Read the article

  • Performance in SQL Mobile with one big column that's not being selected

    - by Anthony Mastrean
    I have a SQL Mobile database with one table. It has several columns with useful, often queried data and one column that stores a relatively large string per record (1000+ characters) that is not queried often. Imagine this fake schema, the "lifeStory" field is the large one. table1 String firstName String lastName String address String lifeStory A representative query would be SELECT firstName, lastName, address FROM table1 WHERE firstName = :p1 Does anyone know of any performance concerns leaving that large, infrequently queried column in this table?

    Read the article

  • How to Configure and run DataBase Mail in SQL Server

    - by Nasser Hajloo
    How to enable and run Database Mail in SQL Server 2008 . I know that it need Enabling Service Broker Configuring SMTP (a Mail server is needed) Using Configuration Storeprocedure. I don't know what's the relation between application and dataBase mail. Actually How to enable Database mail for a RollBack and Commit Transaction ? (not for all SP , just for some of them)

    Read the article

  • Grouping SQL results by continous time intervals (oracle sql)

    - by Kamil Zadora
    Hi I have following data in the table: ID-----startDate----endDate 5549 2008-05-01 4712-12-31 5567 2008-04-17 2008-04-30 1 5567 2008-05-01 2008-07-31 1 5567 2008-09-01 4712-12-31 2 5569 2008-05-01 2008-08-31 5569 2008-09-01 4712-12-31 5589 2008-04-18 2008-04-30 5589 2008-05-01 4712-12-31 5667 2008-05-01 4712-12-31 5828 2008-06-03 4712-12-31 5867 2008-06-03 4712-12-31 6167 2008-11-01 4712-12-31 6207 2008-07-01 4712-12-31 6228 2008-07-01 4712-12-31 6267 2008-07-14 4712-12-31 I am looking for I way to group the continuous time intervals for each id to return: ID, min(startDate), max(endDate), to have something like this in result for the bolded ID 5567 5567 2008-04-17 2008-07-31 5567 2008-09-01 4712-12-31 PL/SQL is also an option here :) Thanks,

    Read the article

  • SQL Server Select Distinct

    - by homam
    I want to write a query like this: For a table that has these columns: ColA ColB ColC, ColD select first(ColA, ColB, ColC, ColD) distinct(ColB, ColC) from table order by ColD The query is supposed to order the table by ColD, then group the results by the combination of ColB and ColC (they may have different data types) and returns the first rows (with all the columns of the table) in the groups. How is it possible in MS SQL Server 2005?

    Read the article

  • sql server modify error

    - by Jaspal
    hi, i m not able to modify table in SQL server. i m new to databases. use work go alter table employee modify id varchar(20) error message is- Msg 102, Level 15, State 1, Line 1 Incorrect syntax near 'modify' here is an screenshot thanks

    Read the article

< Previous Page | 107 108 109 110 111 112 113 114 115 116 117 118  | Next Page >