Search Results

Search found 1805 results on 73 pages for 'varchar'.

Page 15/73 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • LINQ Query Help!

    - by rk1962
    Can someone hep me converting the following SQL query into LINQ? select convert(varchar(10),date,110) as 'Date', max(users) as 'Maximum Number of Users', max(transactions) as 'Maximum Number of Transactions' from stats where datepart(Year, Date) = '2010' group by convert(varchar(10),date,110) order by convert(varchar(10),date,110) Thank you in advance!

    Read the article

  • Is this possible to join tables in doctrine ORM without using relations?

    - by piemesons
    Suppose there are two tables. Table X-- Columns: id x_value Table Y-- Columns: id x_id y_value Now I dont want to define relationship in doctrine classes and i want to retrieve some records using these two tables using a query like this: Select x_value from x, y where y.id="variable_z" and x.id=y.x_id; I m not able to figure out how to write query like this in doctrine orm EDIT: Table structures: Table 1: CREATE TABLE IF NOT EXISTS `image` ( `id` int(11) NOT NULL AUTO_INCREMENT, `random_name` varchar(255) NOT NULL, `user_id` int(11) NOT NULL, `community_id` int(11) NOT NULL, `published` varchar(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=259 ; Table 2: CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `city` varchar(20) DEFAULT NULL, `state` varchar(20) DEFAULT NULL, `school` varchar(50) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=20 ; Query I am using: $q = new Doctrine_RawSql(); $q ->select('{u.*}, {img.*}') ->from('users u LEFT JOIN image img ON u.id = img.user_id') ->addComponent('u', 'Users u') ->addComponent('img', 'u.Image img') ->where("img.community_id='$community_id' AND img.published='y' AND u.state='$state' AND u.city='$city ->orderBy('img.id DESC') ->limit($count+12) ->execute(); Error I am getting: Fatal error: Uncaught exception 'Doctrine_Exception' with message 'Couldn't find class u' in C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Table.php:290 Stack trace: #0 C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Table.php(240): Doctrine_Table- >initDefinition() #1 C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Connection.php(1127): Doctrine_Table->__construct('u', Object(Doctrine_Connection_Mysql), true) #2 C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\RawSql.php(425): Doctrine_Connection- >getTable('u') #3 C:\xampp\htdocs\fanyer\doctrine\models\Image.php(33): Doctrine_RawSql- >addComponent('img', 'u.Image imga') #4 C:\xampp\htdocs\fanyer\community_images.php(31): Image->get_community_images_gallery_filter(4, 0, 'AL', 'ALBERTVILLE') #5 {main} thrown in C:\xampp\htdocs\fanyer\doctrine\lib\Doctrine\Table.php on line 290

    Read the article

  • Getting XQuery [modify()]: Top-level attribute nodes are not supported error while modifying xml

    - by sam
    DECLARE @mycur CURSOR DECLARE @id int DECLARE @ParentNodeName varchar(max) DECLARE @NodeName varchar(max) DECLARE @NodeText varchar(max) SET @mycur = CURSOR FOR SELECT * FROM @temp OPEN @mycur FETCH NEXT FROM @mycur INTO @id,@ParentNodeName,@NodeName,@NodeText WHILE @@FETCH_STATUS = 0 BEGIN PRINT @id -- sample statements PRINT @ParentNodeName PRINT @NodeName SET @x.modify (' insert attribute status {sql:variable("@status")} as first into (/@ParentNodeName/@NodeName/child::*[position()=sql:variable("@status")])[1] ') FETCH NEXT FROM @mycur INTO @id,@ParentNodeName,@NodeName,@NodeText END DEALLOCATE @mycur Any idea why I am getting this error as query works fine if I manually insert path

    Read the article

  • database datatype size

    - by yeeen
    Just to clarify by specifying sth like VARCHAR(45) means it can take up to max 45 characters? I rmb I heard from someone a few years ago that the number in the parathesis doesn't refer to the no of characters, then the person tried to explain to me sth quite complicated which i don't understand n forgot alr. And what is the difference btn CHAR and VARCHAR? I did search ard a bit and see that CHAR gives u the max of the size of the column and it is better to use it if ur data has a fix size and use VARCHAR if ur data size varies. But if it gives u the max of the size of the column of all the data of this col, isn't it better to use it when ur data size varies? Esp if u don't know how big is ur data size gg to be. VARCHAR needs to specify the size (CHAR don't really need right?), isn't it more troublesome?

    Read the article

  • I'm missing something

    - by Redi
    declare @servername varchar(2000) set @EmriServerit=(select @@servername) declare @dbname varchar(2000) set @dbname ='Test1' declare @Dir varchar(2000) set @Dir='F:\dataclient.sql' exec master.dbo.xp_cmdshell 'osql -E -S ' + @servername+ ' -d ' + @dbname +' -i ' + @Dir It gives me and error: "incorrect sysntax near +" If i don't use variables it works ok. What am i missing! Thanks in advance

    Read the article

  • doublechecking: no db-wide 'unicode switch' for sql server in the foreseeable future, i.e. like Orac

    - by user72150
    Hi all, I believe I know the answer to this question, but wanted to confirm: Question Does Sql server (or will it in the foreseeable future), offer a database-wide "unicode switch" which says "store all characters in unicode (UTF-16, UCS-2, etc)", i.e. like Oracle. The Context Our application has provided "CJK" (Chinese-Japanese-Korean) support for years--using Oracle as the db store. Recently folks have been asking for the same support in sql server. We store our db schema definition in xml and generate the vendor-specific definitions (oracle, sql server) using vendor-specific xsl. We can make the change easily. The problem is for upgrades. Generated scripts would need to change the column types for 100+ columns from varchar to nvarchar, varchar(max) to nvarchar(max), etc. These changes require dropping and recreating indexes and foreign keys if the any indexes/fk's exist on the column. Non-trivial. Risky. DB-wide character encodings for us would eliminate programming changes. (I.e. we would not to change the column types from varchar to nvarchar; sql server would correctly store unicode data in varchar columns). I had thought that eventually sql server would "see the light" and allow storing unicode in varchar/clob columns. Evidently not yet. Recap So just to triple check: does mssql offer a database-wide switch for character encoding? Will it in SQL2008R3? or 2010? thanks, bill

    Read the article

  • error in mysql syntax

    - by fusion
    while executing the following query, i get an error that there's an error in the syntax near line 9. since i'm using mysql workbench, i can't really figure out what could be wrong: CREATE TABLE IF NOT EXISTS `proquotes`.`thquotes` ( `idQuotes` INT NOT NULL AUTO_INCREMENT , `vAuthorID` VARCHAR(8) CHARACTER SET 'utf8' NOT NULL , `vAuthor` VARCHAR(45) CHARACTER SET 'utf8' NOT NULL , `cQuotes` MEDIUMTEXT CHARACTER SET 'utf8' NOT NULL , `cArabic` MEDIUMTEXT CHARACTER SET 'utf8' NOT NULL , `vReference` VARCHAR(100) CHARACTER SET 'utf8' NOT NULL , PRIMARY KEY (`idQuotes`) , INDEX `vAuthorID` () , CONSTRAINT `vAuthorID` FOREIGN KEY () REFERENCES `proquotes`.`author_info` () ON DELETE NO ACTION ON UPDATE NO ACTION) DEFAULT CHARACTER SET = utf8;

    Read the article

  • Double of Total Problem

    - by Gopal
    Table1 ID | WorkTime ----------------- 001 | 10:50:00 001 | 00:00:00 002 | .... WorkTime Datatype is *varchar(. SELECT ID, CONVERT(varchar(10), TotalSeconds1 / 3600) + ':' + RIGHT('00' + CONVERT(varchar(2), (TotalSeconds1 - TotalSeconds1 / 3600 * 3600) / 60), 2) + ':' + RIGHT('00' + CONVERT(varchar(2), TotalSeconds1 - (TotalSeconds1 / 3600 * 3600 + (TotalSeconds1 - TotalSeconds1 / 3600 * 3600) / 60 * 60)), 2) AS TotalWork From ( SELECT ID, SUM(DATEDIFF(second, CONVERT(datetime, '1/1/1900'), CONVERT(datetime, '1/1/1900 ' + WorkTime))) AS TotalSeconds1 FROM table1 group by ID) AS tab1 where id = '001' The above Query is showing "double the total of time" For Example From table1 i want to calculate the total WorkTime, when i run the above query it is showing ID WorkTime 001 21:40:00 002..., But it should show like this ID Worktime 001 10:50:00 ..., How to avoid the double total of worktime. How to modify my query. Need Query Help

    Read the article

  • how to get the sql connection

    - by sweetsecret
    FS_Setting is a VB class which has all the details of the connections ie: Public Class FS_Setting Public Function Get_RS_Connection() As SqlConnection Try Get_RS_Connection = New SqlConnection("Data Source=***********;User ID=sa;Password=*****;database=*********") Catch ex As System.Exception Throw New System.Exception("Get_RS_Connection Error:" + ex.Message) End Try End Function I need to call the function Get_RS_Connection() in a different class instead of getting the connection all the way again and hard coding.... I want to call the above class where the SQL connection is declared Namespace FS_Library Public Class FS_Errorlog Inherits FS_BaseClass Try **cn = New SqlConnection("Data Source=***********;UserID=sa;Password=*****;database=*********")** cmd = New SqlCommand("dbo.FS_ErrorLog_ADD", cn) cmd.CommandType = CommandType.StoredProcedure cmd.CommandTimeout = Convert.ToInt32(ConfigurationSettings.AppSettings("Command_Timeout")) Me.AddParameter(cmd, "@p_tableKey", SqlDbType.Int, tableKey) Me.AddParameter(cmd, "@p_FunctionCode", SqlDbType.Int, FunctionCode) Me.AddParameter(cmd, "@p_TableAlias", SqlDbType.VarChar, TableAlias) Me.AddParameter(cmd, "@p_ValidationCode", SqlDbType.Int, ValidationCode) If Filename = "" Then Filename = "N/A" End If Me.AddParameter(cmd, "@p_FileName", SqlDbType.VarChar, Filename) Me.AddParameter(cmd, "@p_Message", SqlDbType.VarChar, Message) Me.AddParameter(cmd, "@p_CreateUser", SqlDbType.VarChar, userID) Me.AddParameter(cmd, "@p_UserActionID", SqlDbType.UniqueIdentifier, UserActionID) cn.Open()

    Read the article

  • Need some tips on my SQL script?

    - by Nano HE
    Hi I plan to create a tale to store the race result like this, Place RaceNumber Gender Name Result 12 0112 Male Mike Lee 1:32:40 16 0117 Female Rose Marry 2:20:40 I confused at the items type definiation. Q1.I am not sure the result can be set to varchar(32) or other type? Q2. and for racenumber, between int(11) and varchar(11), which one is better? Q3. Can I use `UNIQUE KEY` like my way? Q4. Do I need split name to firstName and lastName in my DB table? DROP TABLE IF EXISTS `race_result`; CREATE TABLE IF NOT EXISTS `race_result` ( `id` int(11) NOT NULL auto_increment, `racenumber` int(11) NOT NULL, `gender` enum('male','female') NOT NULL, `name` varchar(16) NOT NULL, `result` varchar(32) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `racenumber` (`racenumber`,`id`) ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 AUTO_INCREMENT=3;

    Read the article

  • migrating from mysql to oracle9i.Equivalent create table syntax

    - by Android_Crazy
    Hi Following is the syntax for creating table in mysql. I want to create table with same properties in oracle9i. Can anyone provide me the equivalent syntax for oracle? CREATE TABLE IF NOT EXISTS "tbl_audit_trail" ( "id" int(11) unsigned NOT NULL, "old_value" text NOT NULL, "new_value" text NOT NULL, "action" varchar(20) CHARACTER SET latin1 NOT NULL, "model" varchar(255) CHARACTER SET latin1 NOT NULL, "field" varchar(64) CHARACTER SET latin1 NOT NULL, "stamp" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "user_id" int(11) NOT NULL, "model_id" varchar(65) CHARACTER SET latin1 NOT NULL, PRIMARY KEY ("id"), KEY "idx_user_id" ("user_id"), KEY "idx_model_id" ("model_id"), KEY "idx_model" ("model"), KEY "idx_field" ("field"), KEY "idx_old_value" ("old_value"(16)), KEY "idx_new_value" ("new_value"(16)), KEY "idx_action" ("action") ) AUTO_INCREMENT=168 ;

    Read the article

  • Best approach, Dynamic OpenXML in T-SQL

    - by Martin Ongtangco
    hello, i'm storing XML values to an entry in my database. Originally, i extract the xml datatype to my business logic then fill the XML data into a DataSet. I want to improve this process by loading the XML right into the T-SQL. Instead of getting the xml as string then converting it on the BL. My issue is this: each xml entry is dynamic, meaning it can be any column created by the user. I tried using this approach, but it's giving me an error: CREATE PROCEDURE spXMLtoDataSet @id uniqueidentifier, @columns varchar(max) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; DECLARE @name varchar(300); DECLARE @i int; DECLARE @xmlData xml; (SELECT @xmlData = data, @name = name FROM XmlTABLES WHERE (tableID = ISNULL(@id, tableID))); EXEC sp_xml_preparedocument @i OUTPUT, @xmlData DECLARE @tag varchar(1000); SET @tag = '/NewDataSet/' + @name; DECLARE @statement varchar(max) SET @statement = 'SELECT * FROM OpenXML(@i, @tag, 2) WITH (' + @columns + ')'; EXEC (@statement); EXEC sp_xml_removedocument @i END where i pass a dynamically written @columns. For example: spXMLtoDataSet 'bda32dd7-0439-4f97-bc96-50cdacbb1518', 'ID int, TypeOfAccident int, Major bit, Number_of_Persons int, Notes varchar(max)' but it kept on throwing me this exception: Msg 137, Level 15, State 2, Line 1 Must declare the scalar variable "@i". Msg 319, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.

    Read the article

  • Union and If Exists - not working together - Please help

    - by needshelp
    I need to get dummy values if they do no rows returned from table. The If exists works by itself, but gives error with a Union. Can someone please guide me with a solution or a workaround? create table test1 (col1 varchar(10)) create table test2 (col1 varchar(10)) create table test3 (col1 varchar(10)) insert test1 values ('test1-row1') insert test1 values ('test1-row2') insert test2 values ('test2-row1') insert test2 values ('test2-row2') select col1 from test1 union select col1 from test2 union if exists (select * from test3) select col1 from test3 else select 'dummy'

    Read the article

  • using check contraint in MySQL for controlling string length not working

    - by ptrn
    Dear stackoverflow, I'm tumbled with a problem! I've set up my first check constraint using MySQL, but unfortunately I'm having a problem. When inserting a row that should fail the test, the row is inserted anyway. The structure: CREATE TABLE user ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, uname VARCHAR(10) NOT NULL, fname VARCHAR(50) NOT NULL, lname VARCHAR(50) NOT NULL, mail VARCHAR(50) NOT NULL, PRIMARY KEY (id), CHECK (LENGTH(fname) > 3) ); The insert statement: INSERT INTO user VALUES (null, 'user', 'Fname', 'Lname', '[email protected]'); I'm pretty sure I'm missing something basic here.

    Read the article

  • Dynamically call a stored procedure from another stored procedure

    - by Greg
    I want to be able to pass in the name of a stored procedure as a string into another stored procedure and have it called with dynamic parameters. I'm getting an error though. Specifically I've tried: create procedure test @var1 varchar(255), @var2 varchar(255) as select 1 create procedure call_it @proc_name varchar(255) as declare @sp_str varchar(255) set @sp_str = @proc_name + ' ''a'',''b''' print @sp_str exec @sp_str exec call_it 'test' So procedure call_it should call procedure test with arguments 'a', and 'b'. When I run the above code I get: Msg 2812, Level 16, State 62, Procedure call_it, Line 6 Could not find stored procedure 'test 'a','b''. However, running test 'a','b' works fine.

    Read the article

  • sql server procedure error

    - by Mohan
    CREATE PROCEDURE USP_SEARCH_HOTELS ( @Text varchar(50), @Type varchar(40) ) AS BEGIN Declare @Query VARCHAR(60) IF @Type = 'By Country' BEGIN SET @Query = 'Hotel.countryName like '+ @Text+'%' END ELSE IF @Type = 'By State' BEGIN SET @Query = 'HOTEL.stateName like '+ @Text+'%' END ELSE IF @Type='By Property Name' BEGIN SET @Query='hotel.propertyname like'+ @Text+'%' End ELSE IF @Type='By Rating' BEGIN SET @Query='hotel.starRating='+ Cast(@Text as INT) END ELSE IF @Type='By City' BEGIN SET @Query='hotel.cityName like '+ @Text+'%' END begin select * from hotel,tbl_cust_info where hotel.agentID=Tbl_Cust_Info.Cust_ID and (@Query) end END WHAT IS THE ERROR IN THIS PROCEDURE PLEASE HELP.

    Read the article

  • Please tell me what is error in my date comparison sql query

    - by Rajesh Rolen- DotNet Developer
    Please help me to find out error in my SQL query. I have created this query to compare dates select * from Joinplans jp where cast(convert(varchar,GETDATE(),103) AS datetime) BETWEEN CASE(convert(varchar,jp.planstartDate,103) AS datetime) AND CASE(convert(varchar,DATEADD(DAY,jp.planDays,jp.planstartDate),103) AS DATETIME) It's giving me the error: incorrect near 'AS' I am using SQL Server 2005.

    Read the article

  • What are the hibernate annotations used to persist a value typed Map with an enumerated type as a ke

    - by Jason Novak
    I am having trouble getting the right hibernate annotations to use on a value typed Map with an enumerated class as a key. Here is a simplified (and extremely contrived) example. public class Thing { public String id; public Letter startLetter; public Map<Letter,Double> letterCounts = new HashMap<Letter, Double>(); } public enum Letter { A, B, C, D } Here are my current annotations on Thing @Entity public class Thing { @Id public String id; @Enumerated(EnumType.STRING) public Letter startLetter; @CollectionOfElements @JoinTable(name = "Thing_letterFrequencies", joinColumns = @JoinColumn(name = "thingId")) @MapKey(columns = @Column(name = "letter", nullable = false)) @Column(name = "count") public Map<Letter,Double> letterCounts = new HashMap<Letter, Double>(); } Hibernate generates the following DDL to create the tables for my MySql database create table Thing (id varchar(255) not null, startLetter varchar(255), primary key (id)) type=InnoDB; create table Thing_letterFrequencies (thingId varchar(255) not null, count double precision, letter tinyblob not null, primary key (thingId, letter)) type=InnoDB; Notice that hibernate tries to define letter (my map key) as a tinyblob, however it defines startLetter as a varchar(255) even though both are of the enumerated type Letter. When I try to create the tables I see the following error BLOB/TEXT column 'letter' used in key specification without a key length I googled this error and it appears that MySql has issues when you try to make a tinyblob column part of a primary key, which is what hibernate needs to do with the Thing_letterFrequencies table. So I would rather have letter mapped to a varchar(255) the way startLetter is. Unfortunately, I've been fussing with the MapKey annotation for a while now and haven't been able to make this work. I've also tried @MapKeyManyToMany(targetEntity=Product.class) without success. Can anyone tell me what are the correct annotations for my letterCounts map so that hibernate will treat the letterCounts map key the same way it does startLetter?

    Read the article

  • CakePHP Bake association problem

    - by Apu
    I have only two tables in my database with a one-to-many relationship between them (user hasMany messages) and am trying to get basic CRUD functionality going. Bake detects the associations correctly and specifies them correctly inside the model classes, but in controllers and views it looks like Cake doesn't know anything about those associations -- I don't even get a select tag for user_id when I go add a new message. Has anyone come across this problem before? What can I be doing wrong? Table structure appears to be fine: CREATE TABLE users ( id int(11) NOT NULL AUTO_INCREMENT, username varchar(255) NOT NULL, `password` varchar(255) NOT NULL, email varchar(255) NOT NULL, created datetime NOT NULL, modified datetime NOT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `messages` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `content` varchar(255) NOT NULL, `created` datetime NOT NULL, `modified` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

    Read the article

  • SSIS: "Failure inserting into the read-only column <ColumnName>"

    - by Cory
    I have an Excel source going into an OLE DB destination. I'm inserting data into a view that has an INSTEAD OF trigger that handles all inserts. When I try to execute the package I receive this error: "Failure inserting into the read-only column ColumnName" What can I do to let SSIS know that this view is safe to insert into because there is an INSTEAD OF trigger that will handle the insert? EDIT (Additional info): Some more additional info. I have a flat file that is being inserted into a normalized database. My initial problem was how do I take a flat file and insert that data into multiple tables while keeping track of all the primary/foreign key relationships. My solution was to create a VIEW that mimicked the structure of the flat file and then create an INSTEAD OF trigger on that view. In my INSTEAD OF trigger I would handle the logic of maintaining all the relationships between tables My view looks something like this. CREATE VIEW ImportView AS SELECT CONVERT(varchar(100, NULL) AS CustomerName, CONVERT(varchar(100), NULL) AS Address1, CONVERT(varchar(100), NULL) AS Address2, CONVERT(varchar(100), NULL) AS City, CONVERT(char(2), NULL) AS State, CONVERT(varchar(250), NULL) AS ItemOrdered, CONVERT(int, NULL) AS QuantityOrdered ... I will never need to select from this view, I only use it to insert data into it from this flat file I receive. I need someway to tell SQL Server that the fields aren't really read only because there is an INSTEAD OF trigger on this view.

    Read the article

  • Please tell me what is error in my date comparision sql query

    - by Rajesh Rolen- DotNet Developer
    please help me to find out error in my sql query. i have created this query to compare dates select * from Joinplans jp where cast(convert(varchar ,GETDATE(),103) AS datetime) BETWEEN CASE(convert(varchar,jp.planstartDate,103) AS datetime) AND CASE(convert(varchar,DATEADD(DAY,jp.planDays,jp.planstartDate),103) AS DATETIME) It's giving me the error: incorrect near 'AS' I am using SQL Server 2005.

    Read the article

  • Can someone explain me the parameter RETURN_VALUE ?

    - by Ronnie Chester Lynwood
    hello. I want to know what does RETURN_VALUE means! I'm stucked at this thing. how to use RETURN_VALUE on MSSQL SP ? thanks.. ASP: Set cmdDB = Server.CreateObject("ADODB.Command") With cmdDB .ActiveConnection = ADOConM .CommandText = "usp_jaljava_member_select" .CommandType = adCmdStoredProc .Parameters.Append .CreateParameter("RETURN_VALUE", adInteger, adParamReturnValue, 0) .Parameters.Append .CreateParameter("@TLoginName", adVarChar, adParamInput, 15,lcase(TLoginName)) .Parameters.Append .CreateParameter("@TPassword", adVarChar, adParamInput, 20,TPassword) .Parameters.Append .CreateParameter("@retval", adVarChar, adParamOutput, 50) ' .Parameters.Append .CreateParameter("@TPinCode", adVarChar, adParamInput, 15,TPinCode) .Execute,,adExecuteNoRecords RetVal = .Parameters("@retval") Ret = Trim(.Parameters("RETURN_VALUE")) 'Set .ActiveConnection = Nothing End With Set cmdDB = Nothing UTid = RetVal MSSQL SP: CREATE PROCEDURE usp_jaljava_member_select @TLoginName varchar(15), @TPassword varchar(20), @retval varchar(50) OUTPUT --@TPinCode varchar(15) AS

    Read the article

  • Newbie question - MySQL index size

    - by Tommy
    I've just started to investigating how I should optimize my database. Indexing seems to be a good idea, so I want to index a VARCHAR column, the engine is MyISAM. From what I've read, I understand that an index is limited to a size of 1000 bytes. A VARCHAR character is 3 bytes in size. Does this mean that if I want to index a VARCHAR column with 50 rows, I need an index prefix of 6 characters? I came to that number by dividing 1000 with the row number 50, then the bytesize per character that is 3. 1000/50/3=6,66. It seems a little complicated, so I'm just wondering if I'm thinking right? It seems weird to me that you'd only be able to index 333 rows in a VARCHAR column, using a prefix of 1 character.

    Read the article

  • whats wrong in this LINQ synatx?

    - by Saurabh Kumar
    Hi, I am trying to convert a SQL query to LINQ. Somehow my count(distinct(x)) logic does not seem to be working correctly. The original SQL is quite efficient(or so i think), but the generated SQL is not even returning the correct result. I am trying to fix this LINQ to do what the original SQL is doing, AND in an efficient way as the original query is doing. Help here would be really apreciated as I am stuck here :( SQL which is working and I need to make a comparable LINQ of: SELECT [t1].[PersonID] AS [personid] FROM [dbo].[Code] AS [t0] INNER JOIN [dbo].[phonenumbers] AS [t1] ON [t1].[PhoneCode] = [t0].[Code] INNER JOIN [dbo].[person] ON [t1].[PersonID]= [dbo].[Person].PersonID WHERE ([t0].[codetype] = 'phone') AND ( ([t0].[CodeDescription] = 'Home') AND ([t1].[PhoneNum] = '111') OR ([t0].[CodeDescription] = 'Work') AND ([t1].[PhoneNum] = '222') ) GROUP BY [t1].[PersonID] HAVING COUNT(DISTINCT([t1].[PhoneNum]))=2 The LINQ which I made is approximately as below: var ids = context.Code.Where(predicate); var rs = from r in ids group r by new { r.phonenumbers.person.PersonID} into g let matchcount=g.Select(p => p.phonenumbers.PhoneNum).Distinct().Count() where matchcount ==2 select new { personid = g.Key }; Unfortunately, the above LINQ is NOT generating the correct result, and is actually internally getting generated to the SQL shown below. By the way, this generated query is also reading ALL the rows(about 19592040) around 2 times due to the COUNTS :( Wich is a big performance issue too. Please help/point me to the right direction. Declare @p0 VarChar(10)='phone' Declare @p1 VarChar(10)='Home' Declare @p2 VarChar(10)='111' Declare @p3 VarChar(10)='Work' Declare @p4 VarChar(10)='222' Declare @p5 VarChar(10)='2' SELECT [t9].[PersonID], ( SELECT COUNT(*) FROM ( SELECT DISTINCT [t13].[PhoneNum] FROM [dbo].[Code] AS [t10] INNER JOIN [dbo].[phonenumbers] AS [t11] ON [t11].[PhoneType] = [t10].[Code] INNER JOIN [dbo].[Person] AS [t12] ON [t12].[PersonID] = [t11].[PersonID] INNER JOIN [dbo].[phonenumbers] AS [t13] ON [t13].[PhoneType] = [t10].[Code] WHERE ([t9].[PersonID] = [t12].[PersonID]) AND ([t10].[codetype] = @p0) AND ((([t10].[codetype] = @p1) AND ([t11].[PhoneNum] = @p2)) OR (([t10].[codetype] = @p3) AND ([t11].[PhoneNum] = @p4))) ) AS [t14] ) AS [cnt] FROM ( SELECT [t3].[PersonID], ( SELECT COUNT(*) FROM ( SELECT DISTINCT [t7].[PhoneNum] FROM [dbo].[Code] AS [t4] INNER JOIN [dbo].[phonenumbers] AS [t5] ON [t5].[PhoneType] = [t4].[Code] INNER JOIN [dbo].[Person] AS [t6] ON [t6].[PersonID] = [t5].[PersonID] INNER JOIN [dbo].[phonenumbers] AS [t7] ON [t7].[PhoneType] = [t4].[Code] WHERE ([t3].[PersonID] = [t6].[PersonID]) AND ([t4].[codetype] = @p0) AND ((([t4].[codetype] = @p1) AND ([t5].[PhoneNum] = @p2)) OR (([t4].[codetype] = @p3) AND ([t5].[PhoneNum] = @p4))) ) AS [t8] ) AS [value] FROM ( SELECT [t2].[PersonID] FROM [dbo].[Code] AS [t0] INNER JOIN [dbo].[phonenumbers] AS [t1] ON [t1].[PhoneType] = [t0].[Code] INNER JOIN [dbo].[Person] AS [t2] ON [t2].[PersonID] = [t1].[PersonID] WHERE ([t0].[codetype] = @p0) AND ((([t0].[codetype] = @p1) AND ([t1].[PhoneNum] = @p2)) OR (([t0].[codetype] = @p3) AND ([t1].[PhoneNum] = @p4))) GROUP BY [t2].[PersonID] ) AS [t3] ) AS [t9] WHERE [t9].[value] = @p5 Thanks!

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >