<?xml version="1.0" encoding="utf-8"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>DaniWeb IT Discussion Community - MS SQL</title>
		<link>http://www.daniweb.com/forums/</link>
		<description><![CDATA[Our MS SQL forum is the place for Q&A-style discussions related to Microsoft SQL Server. Note we have an ASP.NET forum to use in tandem to MS SQL. Additionally, there is a Windows Servers and IIS forum within the Networking sub-forum of the Hardware and Software category.]]></description>
		<language>en-US</language>
		<lastBuildDate>Sat, 21 Nov 2009 06:44:14 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.daniweb.com/alphaimages/misc/rss.jpg</url>
			<title>DaniWeb IT Discussion Community - MS SQL</title>
			<link>http://www.daniweb.com/forums/</link>
		</image>
		<item>
			<title>Inserting into temporary table by dynamic query</title>
			<link>http://www.daniweb.com/forums/thread239985.html</link>
			<pubDate>Fri, 20 Nov 2009 10:40:52 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I have created a temporary @table and while inserting ,i am using dynamic sql.But this is not getting executed and throws an error that  
"EXECUTE cannot be used as a source when inserting into a table variable" 
i am using SQLServer2005. 
Dont know where i am going wrong 
  <div...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I have created a temporary @table and while inserting ,i am using dynamic sql.But this is not getting executed and throws an error that <br />
&quot;EXECUTE cannot be used as a source when inserting into a table variable&quot;<br />
i am using SQLServer2005.<br />
Dont know where i am going wrong<br />
 <pre style="margin:20px; line-height:13px">DECLARE @SqlQuery NVARCHAR(4000);<br />
&nbsp; &nbsp; &nbsp; &nbsp; SELECT @SqlQuery='SELECT TOP '+CAST(@no_of_rows as CHAR)+'tblEmployee.id&nbsp;  ,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tblProject.ID, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; FROM&nbsp; &nbsp; &nbsp; &nbsp;  tblBilling (NOLOCK) '<br />
INSERT @table <br />
EXEC @SqlQuery</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>carobee</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239985.html</guid>
		</item>
		<item>
			<title>count non empty xml nodes</title>
			<link>http://www.daniweb.com/forums/thread239572.html</link>
			<pubDate>Wed, 18 Nov 2009 21:54:11 GMT</pubDate>
			<description><![CDATA[If i have some xml in the form 
<root> 
<a>hello</a> 
<b> 
     <bi>hiya</bi> 
     <bii>hey</bii> 
</b> 
<c/> 
<d>hello again</d> 
</root>]]></description>
			<content:encoded><![CDATA[<div>If i have some xml in the form<br />
&lt;root&gt;<br />
&lt;a&gt;hello&lt;/a&gt;<br />
&lt;b&gt;<br />
     &lt;bi&gt;hiya&lt;/bi&gt;<br />
     &lt;bii&gt;hey&lt;/bii&gt;<br />
&lt;/b&gt;<br />
&lt;c/&gt;<br />
&lt;d&gt;hello again&lt;/d&gt;<br />
&lt;/root&gt;<br />
<br />
how can I <br />
<br />
a) count the nodes? i.e. a, b, bi, bii, c, d so 6<br />
b) count the nodes that are non empty a, bi, bii, d so 4<br />
<br />
?<br />
<br />
i have tried <br />
<br />
xmldata.query('count(/root/*)')    ))<br />
<br />
but that only counts the top level nodes and I have no idea where to start with the non empty nodes<br />
<br />
any help will be very much appreciated</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>londonstan</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239572.html</guid>
		</item>
		<item>
			<title>Migrate data from Mysql to Mssql</title>
			<link>http://www.daniweb.com/forums/thread239495.html</link>
			<pubDate>Wed, 18 Nov 2009 16:23:46 GMT</pubDate>
			<description>Hi, 
 
I am trying to transfer some data from a Mysql database onto a Microsoft SQL database. I would need your help on how to operate this migration as I am new to MSSQL. I have been looking on Google but there are not a lot of pages on that. Can someone help me? 
 
Thanks.</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I am trying to transfer some data from a Mysql database onto a Microsoft SQL database. I would need your help on how to operate this migration as I am new to MSSQL. I have been looking on Google but there are not a lot of pages on that. Can someone help me?<br />
<br />
Thanks.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>asmikwen</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239495.html</guid>
		</item>
		<item>
			<title>Parent and Child nodes from a table (navigation category table)</title>
			<link>http://www.daniweb.com/forums/thread239171.html</link>
			<pubDate>Tue, 17 Nov 2009 10:26:24 GMT</pubDate>
			<description>Hi all, 
 
I have a single table with both parent and child nodes, and each has an order number in it. 
 
I am trying to write a single query to output them in order, its for a navigation list with categories and sub-categories. 
 
I could manage it in code rather than in the SQL query but it would...</description>
			<content:encoded><![CDATA[<div>Hi all,<br />
<br />
I have a single table with both parent and child nodes, and each has an order number in it.<br />
<br />
I am trying to write a single query to output them in order, its for a navigation list with categories and sub-categories.<br />
<br />
I could manage it in code rather than in the SQL query but it would involve calling a query from within a query loop - which I want to avoid.<br />
<br />
Table:<br />
<br />
 <pre style="margin:20px; line-height:13px">DBID | Title | ParentID | OrderNum<br />
&nbsp;1&nbsp; &nbsp; &nbsp; aaa&nbsp; &nbsp; &nbsp;  0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1<br />
&nbsp;2&nbsp; &nbsp; &nbsp; bbb&nbsp; &nbsp; &nbsp;  0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2<br />
&nbsp;3&nbsp; &nbsp; &nbsp; ccc&nbsp; &nbsp; &nbsp;  1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1<br />
&nbsp;4&nbsp; &nbsp; &nbsp; ddd&nbsp; &nbsp; &nbsp;  1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2<br />
&nbsp;5&nbsp; &nbsp; &nbsp; eee&nbsp; &nbsp; &nbsp;  2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1</pre><br />
and I want to get a result set like:<br />
 <pre style="margin:20px; line-height:13px">DBID | Title | ParentID | OrderNum<br />
&nbsp;1&nbsp; &nbsp; &nbsp; aaa&nbsp; &nbsp; &nbsp;  0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1&nbsp; &nbsp; &nbsp; &lt;&lt;&lt; main <br />
&nbsp;3&nbsp; &nbsp; &nbsp; ccc&nbsp; &nbsp; &nbsp;  1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1&nbsp; &nbsp; &nbsp; &lt;&lt;&lt; child<br />
&nbsp;4&nbsp; &nbsp; &nbsp; ddd&nbsp; &nbsp; &nbsp;  1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2&nbsp; &nbsp; &nbsp; &lt;&lt;&lt; 2nd child<br />
&nbsp;2&nbsp; &nbsp; &nbsp; bbb&nbsp; &nbsp; &nbsp;  0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1&nbsp; &nbsp; &nbsp; &lt;&lt;&lt; main <br />
&nbsp;5&nbsp; &nbsp; &nbsp; eee&nbsp; &nbsp; &nbsp;  2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1&nbsp; &nbsp; &nbsp; &lt;&lt;&lt; child</pre><br />
I have been looking at using a recursive SQL select or Common Table Expressions (CTE) but have not been able to figure it out yet.<br />
<br />
Can anyone help point me in the right direction?<br />
<br />
(Using SQL Server 2005 / ASP.Net C#)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>shibbard</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread239171.html</guid>
		</item>
		<item>
			<title>My Insert statement needs a trim</title>
			<link>http://www.daniweb.com/forums/thread238879.html</link>
			<pubDate>Mon, 16 Nov 2009 09:57:51 GMT</pubDate>
			<description>Hi, 
 
I have an insert statement that i need to refine...basically I need to trim the first couple of letters of whats trapped inthe field. 
so e.g.  
 
Z:\aaa\1.jpg  
 
needs to become  
 
aaa\1.jpg</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I have an insert statement that i need to refine...basically I need to trim the first couple of letters of whats trapped inthe field.<br />
so e.g. <br />
<br />
Z:\aaa\1.jpg <br />
<br />
needs to become <br />
<br />
aaa\1.jpg<br />
<br />
Im tried this but its not working<br />
<br />
 <pre style="margin:20px; line-height:13px">sImagelink = mid(request.form(&quot;Imagelink&quot;),4,len(request.form(&quot;Imagelink&quot;)))</pre><br />
any ideas?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>kegathor</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238879.html</guid>
		</item>
		<item>
			<title>SQL SUM Decimals</title>
			<link>http://www.daniweb.com/forums/thread238498.html</link>
			<pubDate>Sat, 14 Nov 2009 14:48:20 GMT</pubDate>
			<description><![CDATA[Hi all... 
So, I am needing to sum all billable hours within a table... the problem is that it is returning rouded decimals instead... like .5 always comes back as 1 ...  
 
Here is my procedure: 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Hi all...<br />
So, I am needing to sum all billable hours within a table... the problem is that it is returning rouded decimals instead... like .5 always comes back as 1 ... <br />
<br />
Here is my procedure:<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; Public Shared Function GetBillableTimeForTicket(ByVal SupportTicketID As Integer) As Decimal<br />
&nbsp; &nbsp; &nbsp; &nbsp; Dim conn As New SqlConnection(GetConnectionString(&quot;ClientPortal.My.MySettings.conString&quot;))<br />
&nbsp; &nbsp; &nbsp; &nbsp; Dim sP As String = &quot;GetBillableTimeForTicket&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Dim cmd As New SqlCommand()<br />
&nbsp; &nbsp; &nbsp; &nbsp; cmd.Parameters.Clear()<br />
&nbsp; &nbsp; &nbsp; &nbsp; cmd.CommandText = sP<br />
&nbsp; &nbsp; &nbsp; &nbsp; cmd.CommandType = CommandType.StoredProcedure<br />
&nbsp; &nbsp; &nbsp; &nbsp; cmd.Parameters.AddWithValue(&quot;@SupportTicketID&quot;, SupportTicketID)<br />
&nbsp; &nbsp; &nbsp; &nbsp; Dim parameter1 As New SqlParameter(&quot;@TotalBillableTime&quot;, SqlDbType.Decimal)<br />
&nbsp; &nbsp; &nbsp; &nbsp; parameter1.Direction = ParameterDirection.Output<br />
&nbsp; &nbsp; &nbsp; &nbsp; cmd.Parameters.Add(parameter1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; cmd.Connection = conn<br />
&nbsp; &nbsp; &nbsp; &nbsp; Try<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HandleConnection(conn)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmd.ExecuteNonQuery()<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Try<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim totalBillableTime As Decimal = Decimal.Parse(cmd.Parameters(&quot;@TotalBillableTime&quot;).Value.ToString())<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return totalBillableTime<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Catch ex As Exception<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MsgBox(ex.Message)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End Try<br />
&nbsp; &nbsp; &nbsp; &nbsp; Catch ex As Exception<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MsgBox(ex.Message)<br />
&nbsp; &nbsp; &nbsp; &nbsp; Finally<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HandleConnection(conn)<br />
&nbsp; &nbsp; &nbsp; &nbsp; End Try<br />
&nbsp; &nbsp; End Function</pre><br />
And here is my StoredProcedure... I have tried so many variations of this SUM... Here is my latest...<br />
 <pre style="margin:20px; line-height:13px">ALTER PROCEDURE dbo.GetBillableTimeForTicket<br />
&nbsp; &nbsp; &nbsp; &nbsp; (<br />
&nbsp; &nbsp; &nbsp; &nbsp; @SupportTicketID int,<br />
&nbsp; &nbsp; &nbsp; &nbsp; @TotalBillableTime decimal (18,2) output<br />
&nbsp; &nbsp; &nbsp; &nbsp; )<br />
As<br />
&nbsp; Set NoCount On;<br />
&nbsp; <br />
&nbsp; SELECT @TotalBillableTime = ROUND(SUM(SupportTicketResponseBillableTime),2) FROM SupportTicketResponses WHERE SupportTicketID = @SupportTicketID;</pre><br />
Any help would be greatly appreciated, thank you in advance... Oh BTW... I'm using SQL 2008 with .NET 3.5</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>webwiredit</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238498.html</guid>
		</item>
		<item>
			<title>Combine all result into one variable</title>
			<link>http://www.daniweb.com/forums/thread238380.html</link>
			<pubDate>Fri, 13 Nov 2009 20:46:51 GMT</pubDate>
			<description>Hello, 
 
I am trying to make this code to combine the varchar string using fetch technique. 
The purpose for the code below is to combine all of the results and display back as 1 record instead of multiple records. 
 
We have SQL 2000 server. 
 
Thanks guys 
 
CREATE PROCEDURE get_all_clumns_name</description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I am trying to make this code to combine the varchar string using fetch technique.<br />
The purpose for the code below is to combine all of the results and display back as 1 record instead of multiple records.<br />
<br />
We have SQL 2000 server.<br />
<br />
Thanks guys<br />
<br />
 <pre style="margin:20px; line-height:13px">CREATE PROCEDURE get_all_clumns_name<br />
(<br />
@table_name&nbsp; varchar(200)<br />
)<br />
<br />
AS<br />
declare @current int<br />
declare @columns_names_holder varchar(500)<br />
declare @columns_names varchar(200)<br />
set @current=0<br />
DECLARE authors_cursor CURSOR FOR<br />
select&nbsp; top 5 col.name&nbsp;  from sysobjects obj inner join syscolumns col on obj.id = col.id where obj.name = @table_name ORDER BY col.name<br />
<br />
OPEN authors_cursor<br />
-- Perform the first fetch and store the values in variables.<br />
-- Note: The variables are in the same order as the columns<br />
<br />
--http://msdn.microsoft.com/en-us/library/aa258896(SQL.80).aspx<br />
FETCH NEXT FROM authors_cursor INTO @columns_names<br />
<br />
-- Check @@FETCH_STATUS to see if there are any more rows to fetch.<br />
<br />
WHILE @@FETCH_STATUS = 0<br />
<br />
BEGIN<br />
set @current=@current+1<br />
&nbsp;  -- This is executed as long as the previous fetch succeeds.<br />
set @columns_names_holder=@columns_names_holder+CONVERT(varchar(200), @columns_names_holder)<br />
&nbsp;  FETCH NEXT FROM authors_cursor&nbsp;  INTO @columns_names<br />
<br />
END<br />
<br />
CLOSE authors_cursor<br />
DEALLOCATE authors_cursor<br />
<br />
--output back the result<br />
select all_columns= @columns_names_holder<br />
GO</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>oimenoi</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238380.html</guid>
		</item>
		<item>
			<title>Joining two views</title>
			<link>http://www.daniweb.com/forums/thread238295.html</link>
			<pubDate>Fri, 13 Nov 2009 14:50:53 GMT</pubDate>
			<description>Hi, this is giving me a major headache and my boss wants the project wrapped up asap : / 
 
I have two views pulling data from several tables. The end result is this: 
 
CustomerTotals 
CustomerID numeric(18,0), 
ProductID numeric(18,0), 
Delivered numeric(5,0), 
Ordered numeric(5,0)</description>
			<content:encoded><![CDATA[<div>Hi, this is giving me a major headache and my boss wants the project wrapped up asap : /<br />
<br />
I have two views pulling data from several tables. The end result is this:<br />
<br />
CustomerTotals<br />
CustomerID numeric(18,0),<br />
ProductID numeric(18,0),<br />
Delivered numeric(5,0),<br />
Ordered numeric(5,0)<br />
<br />
SupplierTotals<br />
SupplierID numeric(18,0),<br />
ProductID numeric(18,0),<br />
Delivered numeric(5,0),<br />
Ordered numeric(5,0)<br />
<br />
CustomerTotals shows total of orders we have recieved and items we have sent out. SupplierTotals shows the total we have ordered from our suppliers and how many we have so far received.<br />
<br />
I need to calculate some values from these but i tried to create the following view and each row is duplicated : /<br />
<br />
 <pre style="margin:20px; line-height:13px">SELECT&nbsp; &nbsp;  ISNULL(st.ProductID, ct.ProductID) AS 'ID', ISNULL(st.Ordered, 0) - ISNULL(st.Delivered, 0) AS [On Order], ISNULL(st.Delivered, 0) - ISNULL(ct.Delivered, 0) <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AS [In Stock], ISNULL(ct.Ordered, 0) - ISNULL(ct.Delivered, 0) AS [Orders Outstanding], ISNULL(st.Ordered, 0) - ISNULL(ct.Ordered, 0) AS Unassigned<br />
FROM&nbsp; &nbsp; &nbsp; &nbsp;  dbo.SupplierTotals AS st FULL OUTER JOIN<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dbo.CustomerTotals AS ct ON st.ProductID = ct.ProductID</pre><br />
Can anyone shed some light on where i'm going wrong? C#.net is my strong suit...SQL is still a very alien language to me lol</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>Ryshad</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238295.html</guid>
		</item>
		<item>
			<title>joining 3 tables messes up SUMS</title>
			<link>http://www.daniweb.com/forums/thread238101.html</link>
			<pubDate>Thu, 12 Nov 2009 19:51:29 GMT</pubDate>
			<description><![CDATA[I have a query that works, I wanted to add another sum from another table, but when I do, the all the SUM values are wrong 
this works 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>I have a query that works, I wanted to add another sum from another table, but when I do, the all the SUM values are wrong<br />
this works<br />
 <pre style="margin:20px; line-height:13px">SELECT&nbsp; &nbsp;  Clients.ClientID, Clients.WholeName, <br />
SUM(CASE WHEN Payments.Creditorid = 0 THEN Payments.Amount ELSE 0.00 END) AS 'Admin Fees', <br />
SUM(CASE WHEN (Payments.Creditorid = 3) THEN Payments.amount ELSE 0.00 END) AS 'Retainer Fees', <br />
SUM(CASE WHEN (Payments.Creditorid = 4) THEN Payments.amount ELSE 0.00 END) AS 'Finance Fees', <br />
SUM(CASE WHEN (Payments.Creditorid = 2) THEN Payments.amount ELSE 0.00 END) AS 'NSF Fees', <br />
SUM(CASE WHEN Payments.bankaccountid = 0 THEN Payments.amount ELSE 0.00 END) AS Settlements&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
FROM&nbsp; &nbsp; &nbsp; &nbsp;  Clients LEFT OUTER JOIN<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Payments ON Clients.ClientID = Payments.ClientID<br />
WHERE&nbsp; &nbsp;  (Clients.ClientID = 1126)<br />
GROUP BY Clients.ClientID, Clients.WholeName<br />
ORDER BY Clients.ClientID</pre><br />
this does not<br />
 <pre style="margin:20px; line-height:13px">SELECT&nbsp; &nbsp;  Clients.ClientID, Clients.WholeName, <br />
SUM(CASE WHEN Payments.Creditorid = 0 THEN Payments.Amount ELSE 0.00 END) AS 'Admin Fees', <br />
SUM(CASE WHEN (Payments.Creditorid = 3) THEN Payments.amount ELSE 0.00 END) AS 'Retainer Fees', <br />
SUM(CASE WHEN (Payments.Creditorid = 4) THEN Payments.amount ELSE 0.00 END) AS 'Finance Fees', <br />
SUM(CASE WHEN (Payments.Creditorid = 2) THEN Payments.amount ELSE 0.00 END) AS 'NSF Fees', <br />
SUM(CASE WHEN Payments.bankaccountid = 0 THEN Payments.amount ELSE 0.00 END) AS Settlements,<br />
&nbsp;SUM(Receipts.ReceiptAmount) AS 'Total Receipts'<br />
FROM&nbsp; &nbsp; &nbsp; &nbsp;  Clients LEFT OUTER JOIN<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Receipts ON Clients.ClientID = Receipts.ClientID LEFT OUTER JOIN<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Payments ON Clients.ClientID = Payments.ClientID<br />
WHERE&nbsp; &nbsp;  (Clients.ClientID = 1126)<br />
GROUP BY Clients.ClientID, Clients.WholeName<br />
ORDER BY Clients.ClientID</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>_taz_</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238101.html</guid>
		</item>
		<item>
			<title>Simple Database Question</title>
			<link>http://www.daniweb.com/forums/thread238086.html</link>
			<pubDate>Thu, 12 Nov 2009 18:41:47 GMT</pubDate>
			<description><![CDATA[Iam writing (or trying to write) a simple join query statement in Query Analyzer. As of right now Im getting the error message  
Ambiguous column name 'categoryID'. 
 
My Statement is ; 
 
Select categoryID, Max (StockPrice) as maxStockPrice, MIN(StockPrice) as minStockPrice, AVG(StockPrice) as...]]></description>
			<content:encoded><![CDATA[<div>Iam writing (or trying to write) a simple join query statement in Query Analyzer. As of right now Im getting the error message <br />
Ambiguous column name 'categoryID'.<br />
<br />
My Statement is ;<br />
<br />
 <pre style="margin:20px; line-height:13px">Select categoryID, Max (StockPrice) as maxStockPrice, MIN(StockPrice) as minStockPrice, AVG(StockPrice) as avgStockPrice<br />
From Category, InventoryPart<br />
Where Category.CategoryID = InventoryPart.CategoryID;</pre><br />
<br />
Im thinking it has something to do with the fact that SQL isn't sure if it should pull the column categoryID from the Category Table or InventoryPart Table.<br />
<br />
1) Am I correct in thinking the above <br />
2) how do I fix it?<br />
<br />
Any Help Would be Greatly Appreciated</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>geek_till_itMHZ</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238086.html</guid>
		</item>
		<item>
			<title>Problem with Datepart</title>
			<link>http://www.daniweb.com/forums/thread238036.html</link>
			<pubDate>Thu, 12 Nov 2009 14:12:27 GMT</pubDate>
			<description><![CDATA[Good Day all 
 
i have the Following Query 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a>...]]></description>
			<content:encoded><![CDATA[<div>Good Day all<br />
<br />
i have the Following Query<br />
 <pre style="margin:20px; line-height:13px">DECLARE @CurrentTime DATETIME<br />
SET @CurrentTime = CURRENT_TIMESTAMP<br />
select tr.Descr [Room], tb.Purpose [Purpose], tb.Description [Description],<br />
convert(varchar,datepart(hour,tb.starttime))+':'+convert(varchar,datepart(minute,tb.starttime)) [Start Time],<br />
convert(varchar,datepart(hour,tb.endtime))+':'+convert(varchar,datepart(minute,tb.endtime)) [End Time],<br />
tu.name [Requested by] from tbl_booking tb inner join tbl_resource tr<br />
on tb.resources = tr.id<br />
inner join tbl_user tu on tu.id = tb.RequestedByUser<br />
where (day(startdate) = day(@CurrentTime))and(month(startdate)=month(@CurrentTime))and(year(startdate)=year(@CurrentTime))and(tb.status=1)<br />
order by [Room],[Start Time]</pre><br />
and in the [Start Time]and [End Time] it gives me time that is not Complete<br />
<br />
it Gives this<br />
<br />
<div style="margin:20px; margin-top:5px; "> <div class="smallfont" style="margin-bottom:2px">Quote:</div> <table cellpadding="5" cellspacing="0" border="0" width="100%"> <tr> <td class="alt2"> <hr />  14:0  <hr /> </td> </tr> </table> </div><br />
instead of<br />
<br />
<div style="margin:20px; margin-top:5px; "> <div class="smallfont" style="margin-bottom:2px">Quote:</div> <table cellpadding="5" cellspacing="0" border="0" width="100%"> <tr> <td class="alt2"> <hr />   14:00  <hr /> </td> </tr> </table> </div>Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>vuyiswamb</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238036.html</guid>
		</item>
		<item>
			<title>SQL Bulk import routine</title>
			<link>http://www.daniweb.com/forums/thread238001.html</link>
			<pubDate>Thu, 12 Nov 2009 11:22:15 GMT</pubDate>
			<description><![CDATA[I am trying to write a bulk import routine so that i will be able to import text files or csv files to SQL i have tried this and it's giving me the following error message. P: is the drive where the file is in currently. 
  <div class="codeblock"> <div class="spaced"> <div style="float:right;...]]></description>
			<content:encoded><![CDATA[<div>I am trying to write a bulk import routine so that i will be able to import text files or csv files to SQL i have tried this and it's giving me the following error message. P: is the drive where the file is in currently.<br />
 <pre style="margin:20px; line-height:13px">USE [XYZABQ]<br />
GO<br />
CREATE TABLE CSVTest<br />
(ID INT,<br />
[Name] VARCHAR(40),<br />
Surname VARCHAR(40),<br />
BirthDate DATETIME (10))<br />
GO<br />
BULK<br />
INSERT CSVTest<br />
FROM 'P:\csvtest.txt'<br />
WITH<br />
(<br />
FIELDTERMINATOR = ',',<br />
ROWTERMINATOR = '\n'<br />
)<br />
GO</pre><span style="color:Green">Error Message</span><br />
<span style="color:red">Msg 4861, Level 16, State 1, Line 2<br />
Cannot bulk load because the file &quot;P:\csvtest.txt&quot; could not be opened. Operating system error code 3(error not found).</span></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>wchitamb</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread238001.html</guid>
		</item>
		<item>
			<title>SQL 2005</title>
			<link>http://www.daniweb.com/forums/thread237829.html</link>
			<pubDate>Wed, 11 Nov 2009 19:54:44 GMT</pubDate>
			<description><![CDATA[Hi, 
I am doing a project where i am creating a website with a SQL server 2005 DB in the backend. I am doing it using visual studio.net and coding in C#, ASP.NET & CSS. 
As a person registers on the website, the info goes to the DB but i want an email to be sent automatically to the person saying...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
I am doing a project where i am creating a website with a SQL server 2005 DB in the backend. I am doing it using visual studio.net and coding in C#, ASP.NET &amp; CSS.<br />
As a person registers on the website, the info goes to the DB but i want an email to be sent automatically to the person saying they have registered successfully,.<br />
What is the best way of doing this??<br />
Please Help<br />
<br />
:)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>Rebel1</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237829.html</guid>
		</item>
		<item>
			<title>SSIS skip bad row</title>
			<link>http://www.daniweb.com/forums/thread237782.html</link>
			<pubDate>Wed, 11 Nov 2009 15:49:02 GMT</pubDate>
			<description><![CDATA[I have a SSIS import file that imports a flat file that is in cvs format. I've been running into a problem where the input file that is retrieved from a third party has bad rows in it. These rows cause the import process to fail and it doesn't fully update the database. Is there a way to tell the...]]></description>
			<content:encoded><![CDATA[<div>I have a SSIS import file that imports a flat file that is in cvs format. I've been running into a problem where the input file that is retrieved from a third party has bad rows in it. These rows cause the import process to fail and it doesn't fully update the database. Is there a way to tell the SSIS package to skip any rows that can't be imported? Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>csihosting</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237782.html</guid>
		</item>
		<item>
			<title>create multiple rows based on data</title>
			<link>http://www.daniweb.com/forums/thread237759.html</link>
			<pubDate>Wed, 11 Nov 2009 13:58:44 GMT</pubDate>
			<description>Dear all, 
 
I’m stuck on a problem which I’m hoping someone might be able to help with in an SQL script. 
 
I have a table with RAW Timesheet data which includes entries for Absences. When someone enters a timesheet on a particular date for a two week holiday, if I report on the amount of hours...</description>
			<content:encoded><![CDATA[<div>Dear all,<br />
<br />
I’m stuck on a problem which I’m hoping someone might be able to help with in an SQL script.<br />
<br />
I have a table with RAW Timesheet data which includes entries for Absences. When someone enters a timesheet on a particular date for a two week holiday, if I report on the amount of hours recorded in the first week, it brings into account the next week’s absences as well.<br />
My solution is that, when the data is imported from the Timesheet system into the SQL database, I want it to identify Absence records greater than one day and then create multiple records for each day taken. This way, I will always get accurate reports regardless of the date range of a report.<br />
I am not great at scripting and am a little out of my depth but thought I would include where I have got up to (stuck though it be) to see if someone can see how to do this better or correct my mistakes.<br />
<br />
The Timesheet record comes from a Timesheet table which is imported from a TXT file. The TimeDate field is the date the timesheet is entered OR the date for the first day’s holiday. The AbsenceDays field is how many days.<br />
<br />
What I want to do is create a new record for every single day BUT, as it is creating each record, check the date against a Calendar table which checks to see if the proposed new record date is a WorkDay or not. The calendar has a [Date] field and a WorkDay Y/N field which is set to No if it is a weekend or is a Public Holiday.<br />
<br />
Each Record it creates INTO a new table called Absences (which I haven’t included – but know needs to go after the print DATEADD but don’t know what to add) and the TimeDate is modified to the date created from the @counter increment and each AbsenceDays is set to 1 with exception to any remainder on the last record (like in the example of 3.5 days – records for 1, 1, 1, 0.5 would be created).<br />
<br />
Sorry if this all looks convoluted but I wanted to ensure I explained myself fully before posting. Thank you all in advance.<br />
<br />
Kind Regards<br />
<br />
Matt<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px"><br />
-- ****** Modified Version ******<br />
<br />
declare @StartDate datetime<br />
declare @Days int<br />
declare @counter int<br />
<br />
set @StartDate = dbo.Timesheets.TimeDate<br />
<br />
if dbo.timesheets.AbsenceDays = &lt;1 THEN<br />
end<br />
else<br />
<br />
set @counter = 0<br />
<br />
-- The reason why counter is set to 0 and not 1 is because I want to create the initial record with the Timesheet date+0.&nbsp; This is because I do not want to keep the original record that is being used to duplicate and create each day timesheet.<br />
<br />
while(@counter &lt;= dbo.timesheets.AbsenceDays)<br />
begin<br />
<br />
-- Somehow need to specify a relationship between dbo.Calendar.[Date] and dbo.timesheets.DateTime+@counter<br />
<br />
CASE WHEN(dbo.Calendar.WorkDay = “Y” THEN continue ELSE @counter = @counter+1 redo case END)<br />
<br />
-- Above case done to ensure that the date it is about to add is not a Sunday or Saturday or public holiday.&nbsp; Don’t know how to format it correctly.<br />
<br />
print DATEADD(day, @counter, @StartDate)<br />
<br />
-- I know I can insert record here but don’t know how.&nbsp; I want the same details as the original record being checked by the script but the TimeDate field to be changed to the new date and the AbsenceDays field to be set to 1 per records.&nbsp; In addition, if the absences are 3.5 days, I would need FOUR records created – 1, 1, 1, 0.5.&nbsp; When adding these records, how would I get it to create records which are not simply divided by 4? (namely 0.87 days per record)[/green]<br />
<br />
set @counter = @counter + 1<br />
end</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>mattlightbourn</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237759.html</guid>
		</item>
		<item>
			<title>SQL</title>
			<link>http://www.daniweb.com/forums/thread237665.html</link>
			<pubDate>Wed, 11 Nov 2009 06:38:53 GMT</pubDate>
			<description><![CDATA[Hi  
 
I need a help in SQL,There is  table called sales.Its contains the day,sales quantity.If I write sql like below  
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680"...]]></description>
			<content:encoded><![CDATA[<div>Hi <br />
<br />
I need a help in SQL,There is  table called sales.Its contains the day,sales quantity.If I write sql like below <br />
<br />
 <pre style="margin:20px; line-height:13px">select day,Sales_quantity from Sales.</pre><br />
Then result should be <br />
Day                         SalesQuantity<br />
Monday                    20<br />
Monday                    302<br />
Monday                   50<br />
Tuseday                   30<br />
etc..<br />
<br />
The problem is I want  to  get result like below<br />
<br />
Day                           SalesQuantity<br />
Monday                    20,302,50<br />
Tuesday                    30<br />
<br />
There should be ',' sign between two values.How Do I write this kind of SQL.<br />
<br />
Thanks<br />
Tank50</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>Tank50</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237665.html</guid>
		</item>
		<item>
			<title>Stored Procedures to insert into a table</title>
			<link>http://www.daniweb.com/forums/thread237434.html</link>
			<pubDate>Tue, 10 Nov 2009 09:21:40 GMT</pubDate>
			<description><![CDATA[I have some tables that i have created in SQL Server and i want to write a stored Procedure that will insert data on to one of my tables AND also be able to update say if i select record 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>I have some tables that i have created in SQL Server and i want to write a stored Procedure that will insert data on to one of my tables AND also be able to update say if i select record<br />
 <pre style="margin:20px; line-height:13px">CREATE PROCEDURE Sp_cust_SaveCustomer<br />
--ALTER PROCEDURE cust_SaveCustomer<br />
(@id int, <br />
@ Surname varchar(50),<br />
@ Initials varchar(50),<br />
@ SEX_CODE varchar(50)) <br />
AS IF @id=-1 <br />
BEGIN INSERT INTO cust_Customer(Surname,Initials,SEX_CODE) <br />
SELECT @ Surname,@ Initials,@SEX_CODE&nbsp;  <br />
SELECT @@identity <br />
END <br />
ELSE<br />
BEGIN UPDATE cust_Customer <br />
SET <br />
Surname= @ Surname ,<br />
Initials =@ Initials ,<br />
SEX_CODE =@ SEX_CODE&nbsp;  <br />
WHERE id=@id <br />
SELECT @id <br />
END</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>wchitamb</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237434.html</guid>
		</item>
		<item>
			<title>Restore Database from a Remote Backup</title>
			<link>http://www.daniweb.com/forums/thread237240.html</link>
			<pubDate>Mon, 09 Nov 2009 14:39:02 GMT</pubDate>
			<description>Good Day All 
 
am restoring a Database Programatically in Sql. Now if the backup is located in the remote machine i use a Share 
 
 
---Quote--- 
\\Vuyiswa\MyShare\ 
---End Quote---</description>
			<content:encoded><![CDATA[<div>Good Day All<br />
<br />
am restoring a Database Programatically in Sql. Now if the backup is located in the remote machine i use a Share<br />
<br />
<div style="margin:20px; margin-top:5px; "> <div class="smallfont" style="margin-bottom:2px">Quote:</div> <table cellpadding="5" cellspacing="0" border="0" width="100%"> <tr> <td class="alt2"> <hr />  \\Vuyiswa\MyShare\  <hr /> </td> </tr> </table> </div><br />
<br />
but i will get the Following Error<br />
<br />
<div style="margin:20px; margin-top:5px; "> <div class="smallfont" style="margin-bottom:2px">Quote:</div> <table cellpadding="5" cellspacing="0" border="0" width="100%"> <tr> <td class="alt2"> <hr />  Exception caught in: ExecuteStoredProc: The file &quot;\\Vuyiswa\Databases\\REmoteTest33.mdf&quot; is on a network path that is not supported for database files. File 'TNGoedit_Data' cannot be restored to '\\Vuyiswa\Databases\\REmoteTest33.mdf'. Use WITH MOVE to identify a valid location for the file. The file &quot;\\Vuyiswa\Databases\\REmoteTest33_log.ldf&quot; is on a network path that is not supported for database files. File 'TNGoedit_Log' cannot be restored to '\\Vuyiswa\Databases\\REmoteTest33_log.ldf'. Use WITH MOVE to identify a valid location for the file. Problems were identified while planning for the RESTORE statement. Previous messages provide details. RESTORE DATABASE is terminating abnormally. Database 'REmoteTest33' does not exist. Make sure that the name is entered correctly.   <hr /> </td> </tr> </table> </div><br />
<br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>vuyiswamb</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237240.html</guid>
		</item>
		<item>
			<title>is there a way to make an image data type as index?</title>
			<link>http://www.daniweb.com/forums/thread237178.html</link>
			<pubDate>Mon, 09 Nov 2009 09:30:17 GMT</pubDate>
			<description>or even make the searching faster when retreiving data. please kindly help me. thnx.</description>
			<content:encoded><![CDATA[<div>or even make the searching faster when retreiving data. please kindly help me. thnx.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>brenn13</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread237178.html</guid>
		</item>
		<item>
			<title>Delete Rows</title>
			<link>http://www.daniweb.com/forums/thread236999.html</link>
			<pubDate>Sun, 08 Nov 2009 15:23:25 GMT</pubDate>
			<description><![CDATA[Hi 
 
I wonder how I do to remove usersid from 1915 to 1945 for example in MS Sql? 
 
Delete from [dbo].[user] where user ID = 1915 to userID 1945 
When i add that i get this message: 
 
Msg 156, Level 15, State 1, Line 2 
Incorrect syntax near the keyword 'to'. 
Msg 156, Level 15, State 1, Line 3]]></description>
			<content:encoded><![CDATA[<div>Hi<br />
<br />
I wonder how I do to remove usersid from 1915 to 1945 for example in MS Sql?<br />
<br />
 <pre style="margin:20px; line-height:13px">Delete from &#91;dbo&#93;.&#91;user&#93; where user ID = 1915 to userID 1945</pre><br />
When i add that i get this message:<br />
<br />
Msg 156, Level 15, State 1, Line 2<br />
Incorrect syntax near the keyword 'to'.<br />
Msg 156, Level 15, State 1, Line 3<br />
Incorrect syntax near the keyword 'to'.<br />
<br />
Can someone please tell me what is wrong?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>Kaddolas</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236999.html</guid>
		</item>
		<item>
			<title>MS SQL Recursion problem</title>
			<link>http://www.daniweb.com/forums/thread236984.html</link>
			<pubDate>Sun, 08 Nov 2009 13:26:28 GMT</pubDate>
			<description>I have following tables 
table1 
nr_key1 
nr_dad1 
 
table2 
nr_key2 
value 
(repeated ~n times with same nr_key2 and different value)</description>
			<content:encoded><![CDATA[<div>I have following tables<br />
table1<br />
nr_key1<br />
nr_dad1<br />
<br />
table2<br />
nr_key2<br />
value<br />
(repeated ~n times with same nr_key2 and different value)<br />
<br />
in table2 nr_key1 = nr_key2<br />
<br />
After I have iterated through nr_key1 I want to use recursion to select nr_key1 = nr_dad1 and iterate again table2 with the new nr_key1. This should be repeated as long as nr_dad1 is null. I have succesfully got the result but only if nr_key1 = nr_key2 contains values. If table2 is empty for the current nr_key1 my recursion is broken. I receive error if I try to use outer join in my recursion. Also my current solution is quite slow, because I am iterating the whole hierarchy again from each value found in table2. Is it possible to implement some sort of a check?<br />
<br />
Maybe my approach is wrong? Any suggestions will be highly appreciated thanks.<br />
<br />
 <pre style="margin:20px; line-height:13px">with test (NR_KEY1, NR_DAD1, VALUE, leveli)&nbsp; <br />
AS<br />
(<br />
select a.NR_KEY1, a.NR_DAD1, VALUE,<br />
1 as leveli<br />
from table1<br />
right outer join table2 a ON<br />
NR_KEY2 = a.NR_KEY1 where a.NR_KEY1 = 10020<br />
<br />
union all<br />
<br />
select a.NR_KEY1, a.NR_DAD1, e.VALUE, <br />
eh.leveli + 1 as leveli<br />
from table1 e<br />
&nbsp; &nbsp; &nbsp; &nbsp; inner join table2 a ON<br />
&nbsp; &nbsp; &nbsp; &nbsp; e.NR_KEY2 = a.NR_KEY1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inner join test eh ON <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.NR_KEY2 = eh.NR_DAD1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; where e.NR_KEY2 = eh.NR_DAD1<br />
)<br />
select * from test order by leveli</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>elauri</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236984.html</guid>
		</item>
		<item>
			<title>Retrieve row based column having null value in sql2000</title>
			<link>http://www.daniweb.com/forums/thread236768.html</link>
			<pubDate>Sat, 07 Nov 2009 11:59:05 GMT</pubDate>
			<description>Hello 
   i wish to retrieve rows from  a table based on a particular column which contains null values in sql2000 server I try ed a lot but its not working please help me.</description>
			<content:encoded><![CDATA[<div>Hello<br />
   i wish to retrieve rows from  a table based on a particular column which contains null values in sql2000 server I try ed a lot but its not working please help me.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>shine_jose</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236768.html</guid>
		</item>
		<item>
			<title>Tables appear under wrong database in SQL Server Mgmt. Studio Express</title>
			<link>http://www.daniweb.com/forums/thread236606.html</link>
			<pubDate>Fri, 06 Nov 2009 16:54:58 GMT</pubDate>
			<description><![CDATA[Whenever I create a new database from a C# program and create tables for that database, the tables always show up under the creator's default database instead of being listed under the newly created database. This observation is from Microsoft SQL Server Management Studio Express. Is there some...]]></description>
			<content:encoded><![CDATA[<div>Whenever I create a new database from a C# program and create tables for that database, the tables always show up under the creator's default database instead of being listed under the newly created database. This observation is from Microsoft SQL Server Management Studio Express. Is there some setting in Microsoft SQL Server Management Studio Express that I may apply to the users to remedy this?<br />
<br />
FYI: SQL Server 9.0.3042<br />
       SQL Server Management Studio Express 9.00.2047.00</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>lukeser</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236606.html</guid>
		</item>
		<item>
			<title>Connect by prior command</title>
			<link>http://www.daniweb.com/forums/thread236562.html</link>
			<pubDate>Fri, 06 Nov 2009 12:54:36 GMT</pubDate>
			<description>Hi All, 
Can anybody give me a solution how to solve or write a query for this scenario? 
 
there is table called ITT1 with the columns 
 
FATHER, CHILD_NUM, CODE, CODE_QTY 
a 1 b 1 
b 1 c 1.5 
c 1 d 2 
d 1 e 1</description>
			<content:encoded><![CDATA[<div>Hi All,<br />
Can anybody give me a solution how to solve or write a query for this scenario?<br />
<br />
there is table called ITT1 with the columns<br />
<br />
FATHER, CHILD_NUM, CODE, CODE_QTY<br />
a 1 b 1<br />
b 1 c 1.5<br />
c 1 d 2<br />
d 1 e 1<br />
<br />
There are 3 columns father,child_num,code &amp; the code_quantity.<br />
It is explained as 'a' is my FINAL finished good and is produced from raw material 'b' using 1kg.<br />
and here 'b' becomes my finished good and is produced from raw material 'c' using 1kg.<br />
and here 'c' becomes my finished good and is produced from raw material 'd' using 1kg.<br />
and here 'd' becomes my finished good and is produced from raw material 'e' using 1kg.<br />
<br />
now i want how much raw material 'e' is required to produced for eg. 20kg of 'a'<br />
<br />
should i use connect by prior or sub queries will help in this regards.<br />
kindly advice.<br />
<br />
Regards,<br />
Faheem</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>sk.faheemuddin</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236562.html</guid>
		</item>
		<item>
			<title>LEFT JOIN problem</title>
			<link>http://www.daniweb.com/forums/thread236427.html</link>
			<pubDate>Fri, 06 Nov 2009 00:11:40 GMT</pubDate>
			<description>Hi All! 
 
I have 3 tables: 
 
test1 
id     name1 
 1     value1 
 
test2 
id     name2</description>
			<content:encoded><![CDATA[<div>Hi All!<br />
<br />
I have 3 tables:<br />
<br />
test1<br />
id     name1<br />
 1     value1<br />
<br />
test2<br />
id     name2<br />
 1     value2<br />
<br />
test3<br />
id     name3<br />
 3     value3_01<br />
 4     value3_02<br />
<br />
I want to display all records of table test1 with values of table test2 (test1.id = test2.id) and values of test3 (if test.id match with test1.id) - in this case test3 has no common ids with test1  so NULLs are displayed.<br />
How to make sql query to display:<br />
id1     name1   name2    name3<br />
   1     value1   value2     NULL<br />
<br />
I constructed query:<br />
 <pre style="margin:20px; line-height:13px">SELECT t1.id as id1, t1.name1 as name1, t2.name2 as name2, t3.name3 as name3<br />
FROM (test1 t1) LEFT JOIN (test3 t3, test2 t2)<br />
ON (t1.id=t2.id and t1.id=t3.id)</pre>but it gives me:<br />
<br />
id1     name1  name2   name3<br />
   1     value1   NULL     NULL<br />
<br />
name2 is NULL instead of desired &quot;value2&quot;. WHY?<br />
<br />
LEFT JOIN DEFINITION:<br />
SQL LEFT JOIN Keyword<br />
The LEFT JOIN keyword returns all rows from the left table, even if there are no matches in the right table.<br />
<br />
There are no matches in test3 table when joining test1 table so name3 from table3 is NULL in result.<br />
<br />
BUT There are matches in table test2 (test2.id=1 and test1.id=1) so why null is displayed?<br />
<br />
Hope anyone can help me. I am in big trouble.<br />
 <br />
Thanks in advace.<br />
Tom</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>pc131</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236427.html</guid>
		</item>
		<item>
			<title><![CDATA['UPDATE'ing table with same value over and over again!]]></title>
			<link>http://www.daniweb.com/forums/thread236359.html</link>
			<pubDate>Thu, 05 Nov 2009 19:44:33 GMT</pubDate>
			<description><![CDATA[One of the UPDATE queries I am trying to run is not quite working the way I want it to. I know this query is the culprit, but can't quite figure out how to fix it! Here's the story: 
------------------------------------------------------- 
I have 3 tables: let's call them tblUsers, tblDueVisits and...]]></description>
			<content:encoded><![CDATA[<div>One of the UPDATE queries I am trying to run is not quite working the way I want it to. I know this query is the culprit, but can't quite figure out how to fix it! Here's the story:<br />
-------------------------------------------------------<br />
I have 3 tables: let's call them tblUsers, tblDueVisits and tblWindows<br />
tblUsers:  UserID (PK, int), FirstName (char), LastName (char), BirthDate (smalldatetime), etc.<br />
tblDueVisits: UserID (int), DueDate (smalldatetime), WindowName(char). UserID + DueDate together make up the key for this table.<br />
tblWindows: WindowID (int), WindowName (varchar)<br />
tblWindows stores a pre-defined maximum number of records (say 10). This table will, at least, theoretically never change.<br />
Now this is what I have to do:<br />
•	Check how many records a particular User ID (say ID # 1) has in tblDueVisits. For the sake of this example assume there are 5 records.<br />
•	Next, SELECT the TOP 5 WindowName from tblWindows.<br />
•	UPDATE tblDueVisits to store the WindowName in tblDueVisits WHERE UserID = 1.<br />
(The front-end user selects an ID# from a web page’s drop down box)<br />
-----------------------------------------------------<br />
I have written the T-SQL loop statements to do this, but somehow the UPDATE doesn’t work. Specifically, what happens is that the same WindowName gets written 5 times rather than writing the 5 different WindowNames once each!!<br />
<br />
Let me know if I wasn't totally clear about something, or if you need me to post the code for this.<br />
<br />
Thanks!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>SQL_n00b</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236359.html</guid>
		</item>
		<item>
			<title>strong sa password error</title>
			<link>http://www.daniweb.com/forums/thread236119.html</link>
			<pubDate>Thu, 05 Nov 2009 02:52:06 GMT</pubDate>
			<description><![CDATA[hello 
i m using a library management software for which i need sql server 
while installing ms sql 2005 at one point installer gives me this message and throw me out. the message is " To continue, you must provide a strong sa password. To review strong password requirements, click Help on the...]]></description>
			<content:encoded><![CDATA[<div>hello<br />
i m using a library management software for which i need sql server<br />
while installing ms sql 2005 at one point installer gives me this message and throw me out. the message is &quot; To continue, you must provide a strong sa password. To review strong password requirements, click Help on the Authentication Mode page.<br />
<br />
For help, click: http://go.microsoft.com/fwlink?LinkID=20476&amp;ProdName=Microsoft+SQL+Server&amp;ProdVer=9.00.4035.00&amp;EvtSrc=setup.rll&amp;EvtID=SQLSetup90&amp;EvtType=28000&quot;<br />
i cannot complete the installation even after giving various passwords<br />
<br />
pl help me<br />
<br />
thanx in advance</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>bmanish</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread236119.html</guid>
		</item>
		<item>
			<title>Get records from current year</title>
			<link>http://www.daniweb.com/forums/thread235940.html</link>
			<pubDate>Wed, 04 Nov 2009 11:33:05 GMT</pubDate>
			<description>Dear SQL sharks.... 
 
Please somebody help me with this struggle. I have been searching the web for hours now. 
 
I have a table with sales data. In this table i have a columne called SalesAmount, CustomerName and SalesDate(the format i smalldatetime) 
 
Now I would like to retreive all the...</description>
			<content:encoded><![CDATA[<div>Dear SQL sharks....<br />
<br />
Please somebody help me with this struggle. I have been searching the web for hours now.<br />
<br />
I have a table with sales data. In this table i have a columne called SalesAmount, CustomerName and SalesDate(the format i smalldatetime)<br />
<br />
Now I would like to retreive all the records where SalesDate is within current year...How do I do this??<br />
I want to make a sum of this years sales numbers and when i pass newsyear it should start from zero again.<br />
<br />
I really hope somebody can help me!!<br />
<br />
Kristian</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>21KristianN</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235940.html</guid>
		</item>
		<item>
			<title>SSIS Variable is Empty</title>
			<link>http://www.daniweb.com/forums/thread235662.html</link>
			<pubDate>Tue, 03 Nov 2009 13:24:03 GMT</pubDate>
			<description>Good Day all 
 
i have created a Global Variable as depicted in the following Pic 
 
http://www.tiyaneproperties.co.za/SSIS/pic1.JPG 
 
The Following Screen-shot shows how i created my Variable and its Properties 
 
http://www.tiyaneproperties.co.za/SSIS/pic2.JPG 
...</description>
			<content:encoded><![CDATA[<div>Good Day all<br />
<br />
i have created a Global Variable as depicted in the following Pic<br />
<br />
<a rel="nofollow" class="t" href="http://www.tiyaneproperties.co.za/SSIS/pic1.JPG" target="_blank">http://www.tiyaneproperties.co.za/SSIS/pic1.JPG</a><br />
<br />
The Following Screen-shot shows how i created my Variable and its Properties<br />
<br />
<a rel="nofollow" class="t" href="http://www.tiyaneproperties.co.za/SSIS/pic2.JPG" target="_blank">http://www.tiyaneproperties.co.za/SSIS/pic2.JPG<br />
</a><br />
<br />
and the Following Screen-shot shows the Script Editor Properties<br />
<a rel="nofollow" class="t" href="http://www.tiyaneproperties.co.za/SSIS/pic3.JPG" target="_blank"><br />
http://www.tiyaneproperties.co.za/SSIS/pic3.JPG</a><br />
<br />
and the Last pic is the code that write to the XML File<br />
<br />
<a rel="nofollow" class="t" href="http://www.tiyaneproperties.co.za/SSIS/pic4.JPG" target="_blank">http://www.tiyaneproperties.co.za/SSIS/pic4.JPG</a><br />
<br />
The Variable comes back empty and at the end the file comes back empty. So i added a if statement as you can see to make sure that the part that write to the file has no problems.<br />
<br />
Thank you</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>vuyiswamb</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235662.html</guid>
		</item>
		<item>
			<title>Integer or Numeric</title>
			<link>http://www.daniweb.com/forums/thread235596.html</link>
			<pubDate>Tue, 03 Nov 2009 09:18:15 GMT</pubDate>
			<description><![CDATA[Hi, 
I've imported a Visual FoxPro database to MS SQL Server 2008 and had a couple of queries; 
The VFP tables used Numeric(5,0) for the Index fields, but I'm thinking of converting them to Integers in SQL Server. Is there any issues I should be aware of? A co-worker keeps telling me that Integers...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
I've imported a Visual FoxPro database to MS SQL Server 2008 and had a couple of queries;<br />
The VFP tables used Numeric(5,0) for the Index fields, but I'm thinking of converting them to Integers in SQL Server. Is there any issues I should be aware of? A co-worker keeps telling me that Integers are &quot;slower&quot; to search on, which I find a bit hard to believe. I always thought that you would you use Numerics for data that requires precision, such as financial data and Integers for counters whole number id's and so on. Am I wrong or missing something?<br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>Wenners</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235596.html</guid>
		</item>
		<item>
			<title>insert date</title>
			<link>http://www.daniweb.com/forums/thread235554.html</link>
			<pubDate>Tue, 03 Nov 2009 04:31:46 GMT</pubDate>
			<description>how to insert system current date by using sql query in  SQL SERVER 2005</description>
			<content:encoded><![CDATA[<div>how to insert system current date by using sql query in  SQL SERVER 2005</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>pavankotturi</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235554.html</guid>
		</item>
		<item>
			<title>Extract table statistics DDL</title>
			<link>http://www.daniweb.com/forums/thread235483.html</link>
			<pubDate>Mon, 02 Nov 2009 21:58:37 GMT</pubDate>
			<description><![CDATA[Hello everyone, 
 
I searched extensively but was unable to find a solution to this problem. I'm attempting to generate the CREATE STATISTICS statement that was used to create an already existing statistics in an MSSQL db from its name or the table's name. I'm able to obtain the columns and the...]]></description>
			<content:encoded><![CDATA[<div>Hello everyone,<br />
<br />
I searched extensively but was unable to find a solution to this problem. I'm attempting to generate the CREATE STATISTICS statement that was used to create an already existing statistics in an MSSQL db from its name or the table's name. I'm able to obtain the columns and the filter definition, but I cannot find anywhere that specifies the &quot;FULLSCAN&quot;, &quot;SAMPLE&quot; and &quot;STATS_STREAM&quot; WITH options. I am querying the sys.stats and sys.stats_columns.<br />
<br />
Please help me out with this! Thanks!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>vkubushyn</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235483.html</guid>
		</item>
		<item>
			<title>Union identical tables in one view</title>
			<link>http://www.daniweb.com/forums/thread235451.html</link>
			<pubDate>Mon, 02 Nov 2009 19:43:47 GMT</pubDate>
			<description>Hello all, 
 
my first post. 
 
I have identical tables in my db. Is there a way to create a view with dynamic query to combine/union all the identical tables into one view? 
 
dbo.table.x-1 
dbo.table.x-2 
dbo.table.x-3 
dbo.table.x-{n}</description>
			<content:encoded><![CDATA[<div>Hello all,<br />
<br />
my first post.<br />
<br />
I have identical tables in my db. Is there a way to create a view with dynamic query to combine/union all the identical tables into one view?<br />
<br />
dbo.table.x-1<br />
dbo.table.x-2<br />
dbo.table.x-3<br />
dbo.table.x-{n}</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>elauri</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235451.html</guid>
		</item>
		<item>
			<title>SSRS delete blank rows</title>
			<link>http://www.daniweb.com/forums/thread235365.html</link>
			<pubDate>Mon, 02 Nov 2009 14:30:05 GMT</pubDate>
			<description>i am using SSRS 2005. In my dataset there are some blank rows and in SSRS is showing blank rows. Is there a way that i just show rows with data and ignore blank rows. i set the visibility property but it is showing blank line. 
 
dataset: 
 
a 
b 
c 
blank 
d 
blank</description>
			<content:encoded><![CDATA[<div>i am using SSRS 2005. In my dataset there are some blank rows and in SSRS is showing blank rows. Is there a way that i just show rows with data and ignore blank rows. i set the visibility property but it is showing blank line.<br />
<br />
dataset:<br />
<br />
a<br />
b<br />
c<br />
blank<br />
d<br />
blank<br />
blank<br />
e<br />
<br />
i want output like:<br />
<br />
a<br />
b<br />
c<br />
d<br />
e<br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>azamsalam</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235365.html</guid>
		</item>
		<item>
			<title>Help BCP The Following Query</title>
			<link>http://www.daniweb.com/forums/thread235317.html</link>
			<pubDate>Mon, 02 Nov 2009 10:34:19 GMT</pubDate>
			<description><![CDATA[Good Day All  
 
I have the Following Query  
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code...]]></description>
			<content:encoded><![CDATA[<div>Good Day All <br />
<br />
I have the Following Query <br />
 <pre style="margin:20px; line-height:13px">DECLARE @CurrentTime DATETIME<br />
SET @CurrentTime = CURRENT_TIMESTAMP<br />
select tr.Descr [Room], tb.Purpose [Purpose], tb.Description [Description],<br />
convert(varchar,datepart(hour,tb.starttime))+':'+convert(varchar,datepart(minute,tb.starttime)) [Start Time],<br />
convert(varchar,datepart(hour,tb.endtime))+':'+convert(varchar,datepart(minute,tb.endtime)) [End Time],<br />
tu.name [Requested by] from tbl_booking tb inner join tbl_resource tr<br />
on tb.resources = tr.id<br />
inner join tbl_user tu on tu.id = tb.RequestedByUser<br />
where (day(startdate) = day(@CurrentTime))and(month(startdate)=month(@CurrentTime))and(year(startdate)=year(@CurrentTime))and(tb.status=1)<br />
order by [Room],[Start Time]<br />
for xml raw</pre><br />
This creates an XML, but now i want to store it in <br />
<div style="margin:20px; margin-top:5px; "> <div class="smallfont" style="margin-bottom:2px">Quote:</div> <table cellpadding="5" cellspacing="0" border="0" width="100%"> <tr> <td class="alt2"> <hr />  C:\X.XML  <hr /> </td> </tr> </table> </div>how can i BCP this Query <br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>vuyiswamb</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235317.html</guid>
		</item>
		<item>
			<title>SQL question releated to group by</title>
			<link>http://www.daniweb.com/forums/thread235316.html</link>
			<pubDate>Mon, 02 Nov 2009 10:32:49 GMT</pubDate>
			<description>Hi, 
 
I hope someone can help me creating a sql for the purpose i have. 
 
I have a table named case_score_t with these columns: 
id, case_id, user_id, score, created_date 
 
I am interested in picking the rows with the greatest created_date, for a certain user_id. 
 
I now this SQL with give me...</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I hope someone can help me creating a sql for the purpose i have.<br />
<br />
I have a table named case_score_t with these columns:<br />
id, case_id, user_id, score, created_date<br />
<br />
I am interested in picking the rows with the greatest created_date, for a certain user_id.<br />
<br />
I now this SQL with give me the result:<br />
 <pre style="margin:20px; line-height:13px">SELECT *, max(created) FROM case_score_t cs WHERE cs.user_id = 1449 GROUP BY cs.case_id;</pre><br />
The problem is that i have is that i get an extra column, the max(created) column back.<br />
<br />
Is there anyway to do the same query(maybe with subselect's or something), without getting the extra column.<br />
<br />
So basically i want something like:  <pre style="margin:20px; line-height:13px">SELECt * FROM ......</pre>and is should return the same result.<br />
<br />
Thanks in advance.<br />
Cemils</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>Cemils</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235316.html</guid>
		</item>
		<item>
			<title>syntax query for backup database for one month in sql server 2000</title>
			<link>http://www.daniweb.com/forums/thread235205.html</link>
			<pubDate>Mon, 02 Nov 2009 01:55:25 GMT</pubDate>
			<description><![CDATA[hi, 
 
how the way backup database in sql server 2000 with syntax sql for one month, i mean query. Thank's]]></description>
			<content:encoded><![CDATA[<div>hi,<br />
<br />
how the way backup database in sql server 2000 with syntax sql for one month, i mean query. Thank's</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>hery</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread235205.html</guid>
		</item>
		<item>
			<title>Stored Procedure with Increments</title>
			<link>http://www.daniweb.com/forums/thread234691.html</link>
			<pubDate>Fri, 30 Oct 2009 13:44:53 GMT</pubDate>
			<description>I need some help I have managed to get this far (as below), from thatI can put a AAA_NUMBER and be able to get that record details and thats the 1st step that I wanted the 2nd step that I want is say if the DOCID is not available I then need the system to generate a new number (the tricky bit for...</description>
			<content:encoded><![CDATA[<div>I need some help I have managed to get this far (as below), from thatI can put a AAA_NUMBER and be able to get that record details and thats the 1st step that I wanted the 2nd step that I want is say if the DOCID is not available I then need the system to generate a new number (the tricky bit for me now is to have it do the increment since I want the system to 1st look at the current year since each and every year has a different sequence) so the YEAR_SEQUENCE table has CURRENT_YEAR, SEQUENCE, LAST_NUM Fields so it will be incrementing from the last generated number (+1 increment)<br />
<br />
Any suggestions or twicks are welcome!<br />
<br />
 <pre style="margin:20px; line-height:13px">CREATE PROCEDURE Sp_Show_Presc_Num<br />
<br />
@AAA_NUMBER VARCHAR(7) <br />
<br />
AS <br />
<br />
SELECT<br />
&lt;TABLE A&gt;.Surname,<br />
&lt;TABLE A&gt;.Initials,<br />
&lt;TABLE A&gt;.AAA_NUMBER,<br />
&lt;TABLE B&gt;.DOCID,<br />
CONVERT(VARCHAR (10),&lt;TABLE B&gt;.ALLOCATIONDATE,103) AS ALLOCATIONDATE,<br />
&lt;TABLE A&gt;.Sex_Code<br />
FROM &lt;TABLE A&gt;<br />
LEFT JOIN &lt;TABLE B&gt; ON &lt;TABLE B&gt;.BBBNUMBER = &lt;TABLE A&gt;.AAA_NUMBER<br />
WHERE AAA_NUMBER=@AAA_NUMBER</pre><br />
EXECUTION EXAMPLE<br />
---------------------------------------------------------------------USE [TEST DB] <br />
EXEC [Sp_Show_Presc_Num] '4300058'<br />
--------------------------------------------------------------------- <br />
<br />
<span style="font-weight:bold">MORE INFO</span><br />
Some of the them are populated and the DocID should be displayed if available or else if its NULL then there should be an option for the user to have one generated<br />
<br />
The are 3 table<br />
&lt;TABLE A&gt; which will display these fields(Surname, Initials, AAA_NUMBER)<br />
&lt;TABLE B&gt; which will display these fields(DOCID,ALLOCATIONDATE)<br />
&lt;TABLE C&gt; which has these fields (@ the moment)(CURRENT_YEAR, SEQUENCE, LAST_NUM)<br />
<br />
the ALLOCATIONDATE is populated when the DOCID is generated so its on that day</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>wchitamb</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234691.html</guid>
		</item>
		<item>
			<title>MS SQL: Converting row printing to column based printing</title>
			<link>http://www.daniweb.com/forums/thread234309.html</link>
			<pubDate>Thu, 29 Oct 2009 05:14:58 GMT</pubDate>
			<description><![CDATA[Hi, I am doing a student progression system where the application is able to keep track of student marks. I have a problem currently and I've been spending nights on this.  
 
Let me briefly explain. Marks are calculated based on their hurdles. So for instance, H1 = xx%, H2 = xx%. The number of...]]></description>
			<content:encoded><![CDATA[<div>Hi, I am doing a student progression system where the application is able to keep track of student marks. I have a problem currently and I've been spending nights on this. <br />
<br />
Let me briefly explain. Marks are calculated based on their hurdles. So for instance, H1 = xx%, H2 = xx%. The number of hurdles vary for different subjects. The code below is able to provide me the calculated marks based on each individual's hurdles in rows. However, I'm trying to output it in a horizontal format. Meaning:<br />
<br />
Instead of:<br />
<br />
xx%<br />
xx%<br />
<br />
I want it to be: xx% xx% (in two columns)<br />
<br />
I've tried using the CASE clause in my SELECT section but that only works if the hurdles are static and fixed. My problem is the hurdles are dynamic as well. Is there anyone who has some idea on how to workaround this issue? Thanks in advance guys!! :)<br />
<br />
 <pre style="margin:20px; line-height:13px">SELECT&nbsp; &nbsp;  SUM(Marks.marks_value) * Hurdle.hurdle_weight / 100 AS total<br />
FROM&nbsp; &nbsp; &nbsp; &nbsp;  Marks INNER JOIN<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Student ON Marks.student_id = Student.student_id INNER JOIN<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Class ON Student.student_id = Class.student_id INNER JOIN<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MarkingCriteria ON Marks.criteria_id = MarkingCriteria.criteria_id INNER JOIN<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AssessmentComponent ON MarkingCriteria.component_id = AssessmentComponent.component_id INNER JOIN<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Hurdle ON AssessmentComponent.hurdle_id = Hurdle.hurdle_id<br />
GROUP BY Hurdle.hurdle_id, Hurdle.hurdle_weight, Student.student_id, Class.student_id<br />
ORDER BY Hurdle.hurdle_id</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>dfs3000my</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234309.html</guid>
		</item>
		<item>
			<title>Cute: I need to remove the db_backupoperator permissions from the db_owner role.</title>
			<link>http://www.daniweb.com/forums/thread234206.html</link>
			<pubDate>Wed, 28 Oct 2009 22:13:50 GMT</pubDate>
			<description><![CDATA[The reason is that : 
 
1. I wish to run multiple databases on a single server. 
To do this securely each login must be granted db_owner on the database so we can use "deny view any database" to hide the other databases from view. (login can see all databases they are owner of however). 
 
2. This...]]></description>
			<content:encoded><![CDATA[<div>The reason is that :<br />
<br />
1. I wish to run multiple databases on a single server.<br />
To do this securely each login must be granted db_owner on the database so we can use &quot;deny view any database&quot; to hide the other databases from view. (login can see all databases they are owner of however).<br />
<br />
2. This creates a problem. We do not wish the users to be able to create backups even though they are db_owners.<br />
It's here that I am having difficulties. <br />
<br />
Any ideas?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>BratNZ</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234206.html</guid>
		</item>
		<item>
			<title>View Help</title>
			<link>http://www.daniweb.com/forums/thread234162.html</link>
			<pubDate>Wed, 28 Oct 2009 18:39:24 GMT</pubDate>
			<description><![CDATA[In the view below, I need the line "isnull(wwr.packed_qty, isnull((select sum(qty_on_hand) from lot_loc where item = coi.item and loc like 'P%'), 0)) packed_qty, " to include a "or 'S%'", so that both P and S are found, but I get a syntax error when I add it. 
What is the correct syntax that I am...]]></description>
			<content:encoded><![CDATA[<div>In the view below, I need the line &quot;<span style="color:Red">isnull(wwr.packed_qty, isnull((select sum(qty_on_hand) from lot_loc where item = coi.item and loc like 'P%'), 0)) packed_qty,</span> &quot; to include a &quot;<span style="color:red">or 'S%</span>'&quot;, so that both P and S are found, but I get a syntax error when I add it.<br />
What is the correct syntax that I am missing?<br />
This is what I used <span style="color:Green">isnull(wwr.packed_qty, isnull((select sum(qty_on_hand) from lot_loc where item = coi.item and loc like 'P%' or 'S%'), 0)) packed_qty, </span> and got the syntax at 'or' error.<br />
Below is the whole &quot;Current&quot; view.<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px">CREATE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; view [dbo].[SII_vwYardsOnHandDueRpt]<br />
as<br />
SELECT&nbsp; isnull(wwr.greige_item, (select top 1 item from item where family_code = 'GREIGE' and coi.item like item.item + '%')) greige_item, <br />
&nbsp; &nbsp; &nbsp; &nbsp; isnull(wwr.greige_yds, 0) greige_yds, <br />
&nbsp; &nbsp; &nbsp; &nbsp; isnull(wwr.finished_item, (select top 1 item from item where family_code = 'FINISHED' and coi.item like item.item + '%')) finished_item, <br />
&nbsp; &nbsp; &nbsp; &nbsp; isnull(wwr.finished_yds, 0) finished_yds, <br />
&nbsp; &nbsp; &nbsp; &nbsp; isnull(wwr.packed_item, coi.item) packed_item, <br />
&nbsp; &nbsp; &nbsp; &nbsp; isnull(wwr.packed_desc, it.description) packed_desc, <br />
&nbsp; &nbsp; &nbsp; &nbsp; isnull(wwr.packed_qty, isnull((select sum(qty_on_hand) from lot_loc where item = coi.item and loc like 'P%'), 0)) packed_qty, <br />
&nbsp; &nbsp; &nbsp; &nbsp; isnull(wwr.pack_uom, it.u_m) pack_uom, <br />
&nbsp; &nbsp; &nbsp; &nbsp; coi.co_num, <br />
&nbsp; &nbsp; &nbsp; &nbsp; coi.co_line, <br />
&nbsp; &nbsp; &nbsp; &nbsp; coi.co_release, <br />
&nbsp; &nbsp; &nbsp; &nbsp; coi.due_date, <br />
&nbsp; &nbsp; &nbsp; &nbsp; (coi.qty_ordered - coi.qty_shipped) * dbo.SIIItemSalesUOM2(coi.co_num, coi.co_line, coi.co_release) qty_due, <br />
&nbsp; &nbsp; &nbsp; &nbsp; coi.u_m sales_uom, <br />
&nbsp; &nbsp; &nbsp; &nbsp; ca.[name] customer_name,<br />
&nbsp; &nbsp; &nbsp; &nbsp; dbo._SIIQtyDueInYards(coi.co_num, coi.co_line, coi.co_release) qty_due_yds<br />
FROM&nbsp; &nbsp; coitem coi WITH(NOLOCK)<br />
INNER JOIN item it WITH(NOLOCK)<br />
ON&nbsp; &nbsp; &nbsp; it.item = coi.item <br />
LEFT OUTER JOIN co WITH(NOLOCK)<br />
ON&nbsp; &nbsp; &nbsp; co.co_num = coi.co_num <br />
LEFT OUTER JOIN custaddr ca WITH(NOLOCK)<br />
ON&nbsp; &nbsp; &nbsp; ca.cust_num = co.cust_num <br />
&nbsp; &nbsp; AND ca.cust_seq = co.cust_seq <br />
LEFT OUTER JOIN SII_vwWipWebReport wwr <br />
ON&nbsp; &nbsp; &nbsp; wwr.packed_item = coi.item <br />
WHERE&nbsp;  co.stat&nbsp; in ('O', 'S') <br />
&nbsp; &nbsp; AND coi.stat in ('O', 'S')</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>Moordoom</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234162.html</guid>
		</item>
		<item>
			<title>SSIS Permission Problem</title>
			<link>http://www.daniweb.com/forums/thread234084.html</link>
			<pubDate>Wed, 28 Oct 2009 08:08:35 GMT</pubDate>
			<description>Good Day All 
 
I have a Package created and hosted in a Machine(Theresa) that has SQL 2008 and i have my Development Machine(Vuyiswa) that has IIS and am Debugging from the my machine. i have a ASP.NET 2.0 App and am executing a Package that in another machine. The First thing i did was to share a...</description>
			<content:encoded><![CDATA[<div>Good Day All<br />
<br />
I have a Package created and hosted in a Machine(Theresa) that has SQL 2008 and i have my Development Machine(Vuyiswa) that has IIS and am Debugging from the my machine. i have a ASP.NET 2.0 App and am executing a Package that in another machine. The First thing i did was to share a directory where the Packages are stored when i install the packages and supplied &quot;Everyone&quot;,&quot;ASP.NET&quot;,&quot;Vuyiswa&quot; Accounts permissions to to access this share. i can go into the share from the another machine without any problem. i have a code like this in my ASP.NET App<br />
<br />
 <pre style="margin:20px; line-height:13px"> try<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Start the SSIS Here<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Application app = new Application();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Package package = null;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; package = app.LoadPackage(@&quot;D:\Program Files\Microsoft SQL Server\100\DTS\Packages\OMEGA\OMEGA.dtsx&quot;, null);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //@&quot;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Packages\OMEGA\OMEGA.dtsx&quot;, null);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Variables vars = package.Variables;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vars[&quot;Time1&quot;].Value = time;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vars[&quot;Time2&quot;].Value = time;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vars[&quot;Time3&quot;].Value = time;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vars[&quot;TTBLTYPE&quot;].Value = THREAD_DATA[1].ToString();<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //package.Connections[&quot;SQLNCLI10.1&quot;].ConnectionString = obj.GetConnectionString(THREAD_DATA[0].ToString());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Excute Package<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Microsoft.SqlServer.Dts.Runtime.DTSExecResult results = package.Execute();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (results == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach (Microsoft.SqlServer.Dts.Runtime.DtsError local_DtsError in package.Errors)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;Package Execution results: {0}&quot;, local_DtsError.Description.ToString());<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.WriteLine();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; catch (DtsException ex)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exception = ex.Message;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</pre><br />
This execute Fine until the<br />
<br />
 <pre style="margin:20px; line-height:13px"> Microsoft.SqlServer.Dts.Runtime.DTSExecResult results = package.Execute();</pre><br />
it does not stop here , but i trap it here<br />
<br />
 <pre style="margin:20px; line-height:13px"> if (results == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure)</pre>            <br />
<br />
<br />
 and the Error am Getting is<br />
<br />
<span style="font-weight:bold">&quot;SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E4D.\r\nAn OLE DB record is available.  Source:\&quot;Microsoft SQL Server Native Client 10.0&quot;  Hresult: 0x80040E4D  Description:  &quot;Login failed for user 'sa'</span><br />
<br />
On my Package i use the &quot;sa&quot; credentials and my Protection Level is &quot;Dont Save Sensative&quot;<br />
<br />
Thank you<br />
<br />
<br />
Vuyiswa Maseko</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>vuyiswamb</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234084.html</guid>
		</item>
		<item>
			<title>creating headr name dynamically</title>
			<link>http://www.daniweb.com/forums/thread234358.html</link>
			<pubDate>Wed, 28 Oct 2009 06:09:25 GMT</pubDate>
			<description>I created 2 tables 
  
 1  st table as csat 
csat_code        csat_ou_cod   csat_csaeid cus name 
CSA00001	ADM00001	6825	CUS08349 
CSA00002	ADM00001	6826	CUS08347 
CSA00003	ADM00001	6832	CUS08351 
CSA02547	ADM00001	6824	CUS04150</description>
			<content:encoded><![CDATA[<div>I created 2 tables<br />
 <br />
 1  st table as csat<br />
csat_code        csat_ou_cod   csat_csaeid cus name<br />
CSA00001	ADM00001	6825	CUS08349<br />
CSA00002	ADM00001	6826	CUS08347<br />
CSA00003	ADM00001	6832	CUS08351<br />
CSA02547	ADM00001	6824	CUS04150<br />
<br />
<br />
 table2 as csat_survey<br />
<br />
surveycode csat_code         qns id   ans id<br />
SUR00001	CSA02547	1	   3<br />
SUR00002	CSA02547	4	   7<br />
<br />
<br />
now i want the resut is<br />
<br />
<br />
csat_code   csat_case_id      qns id(column name)<br />
<br />
<br />
like  the row field of qns id ( table2) is cloumn for my solution table. and the number of qns also varied .so i have to create the dynamic header.. plz any one help me? how can i get this solution?<br />
<br />
<br />
Thanks in advance<br />
<br />
   Sangita.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>shangita</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234358.html</guid>
		</item>
		<item>
			<title>Smart Searches</title>
			<link>http://www.daniweb.com/forums/thread234052.html</link>
			<pubDate>Wed, 28 Oct 2009 05:46:58 GMT</pubDate>
			<description><![CDATA[Simply put, I need a better query. I have a table that contains 85000 rows, each row has a TITLE and an ABSTRACT (they are academic papers). 
 
What I need is to do a realistic SMART search in my query. 
Right now I'm doing  <div class="codeblock"> <div class="spaced"> <div style="float:right;...]]></description>
			<content:encoded><![CDATA[<div>Simply put, I need a better query. I have a table that contains 85000 rows, each row has a TITLE and an ABSTRACT (they are academic papers).<br />
<br />
What I need is to do a realistic SMART search in my query.<br />
Right now I'm doing <pre style="margin:20px; line-height:13px">SELECT * FROM PsPapers WHERE Title LIKE '%MySearchString%'</pre> which is, as you can see, a fairly retarded search system. This has several problems:<ol style="list-style-type: decimal"><li>If the search is &quot;othello essays&quot; then my query only gives you ones where the title contains &quot;othello essays&quot; even though something like &quot;essays on othello&quot; I would also want to be returned because the title is OBVIOUSLY on point.</li>
<li>My query doesn't use the abstracts right now, the reason is that the abstracts contain alot of crap and should be WEIGHTED MUCH LESS than titles. I would want title matches to list HIGHER than abstract matches.</li>
<li>There is no real cleverness or weighting here. The older cgi system I'm trying to replace uses code taken from an actual search engine so I need to at least ATTEMPT to do a smart search.</li>
</ol><br />
Any thoughts on a better query?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>mmxbass</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234052.html</guid>
		</item>
		<item>
			<title>Connection Strings to network.</title>
			<link>http://www.daniweb.com/forums/thread234019.html</link>
			<pubDate>Wed, 28 Oct 2009 02:49:18 GMT</pubDate>
			<description><![CDATA[it seem my connection string doesnt work? 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a>...]]></description>
			<content:encoded><![CDATA[<div>it seem my connection string doesnt work?<br />
<br />
 <pre style="margin:20px; line-height:13px">$connect = mssql_connect(&quot;192.170.10.798&quot;,&quot;sa&quot;,&quot;gasd&quot;) or die(mssql_error());<br />
$test = mssql_select_db(&quot;banex&quot;, $connect) or die (mssql_error());</pre><br />
whats wrong with my connection string?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>nanat07</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread234019.html</guid>
		</item>
		<item>
			<title>sql convert vertical to horizontal</title>
			<link>http://www.daniweb.com/forums/thread233907.html</link>
			<pubDate>Tue, 27 Oct 2009 15:55:40 GMT</pubDate>
			<description>I am using SQL Server 2005. I have a data from SQL like this. 
 
ID        ID2      PartNo 
 
75        23921  DENT  
75        26145  PLGD  
75        26145  PRRP  
75        26145  SIST  
75        57290  PRMD 
75        57290  abc</description>
			<content:encoded><![CDATA[<div>I am using SQL Server 2005. I have a data from SQL like this.<br />
<br />
ID        ID2      PartNo<br />
<br />
75        23921  DENT <br />
75        26145  PLGD <br />
75        26145  PRRP <br />
75        26145  SIST <br />
75        57290  PRMD<br />
75        57290  abc<br />
75        57290  def<br />
75        57290  ghi<br />
75        57290  jkl<br />
<br />
<br />
I need an output like this. (max Part4)<br />
<br />
ID        ID2    Part1      Part2  Part3  Part4<br />
<br />
75        23921   DENT<br />
75        26145   PLGD   PRRP   SIST<br />
75        57290   PRMD  abc       def       ghi<br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>azamsalam</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread233907.html</guid>
		</item>
		<item>
			<title><![CDATA[How to Create database in SQL Server using Javascript & HTML?]]></title>
			<link>http://www.daniweb.com/forums/thread233881.html</link>
			<pubDate>Tue, 27 Oct 2009 14:16:48 GMT</pubDate>
			<description><![CDATA[Hello, 
 
I want to create database on SQL Server using Javascript and HTML. User will input following data. Server Name, Database name, File Sizes. When I will click "Submit" button database should be created on Selected server with entered name. I am using Client side HTML and Javascript.  
we...]]></description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I want to create database on SQL Server using Javascript and HTML. User will input following data. Server Name, Database name, File Sizes. When I will click &quot;Submit&quot; button database should be created on Selected server with entered name. I am using Client side HTML and Javascript. <br />
we need to create database according to some standards thus we are preparing graphical user interface.<br />
Quick response will be appreciated.<br />
<br />
Thanks, Rahul</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>Rahul002</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread233881.html</guid>
		</item>
		<item>
			<title>Getting sum of cost from one table where quantity on another table</title>
			<link>http://www.daniweb.com/forums/thread233667.html</link>
			<pubDate>Tue, 27 Oct 2009 03:03:02 GMT</pubDate>
			<description><![CDATA[hi guys, I have 2 tables, one called neworders which stores the part_id and num or parts and a 2nd table called parts which has all the part details including cost. 
tables are as follows 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>hi guys, I have 2 tables, one called neworders which stores the part_id and num or parts and a 2nd table called parts which has all the part details including cost.<br />
tables are as follows<br />
 <pre style="margin:20px; line-height:13px">neworder <br />
part_id(primary key)<br />
number_of_parts<br />
<br />
parts<br />
part_id(primary key)<br />
7-8 more columns, eg size, desc, sup id<br />
cost</pre><br />
what i need to do is get the sum of the costs based on the quantity of the parts ordered<br />
<br />
so if table is as follows<br />
<br />
 <pre style="margin:20px; line-height:13px">table new order<br />
part_id number_of_parts<br />
pt12&nbsp; &nbsp;  2<br />
pt255&nbsp;  4</pre><br />
I need to use the part_id of the neworder table to get the costs of the parts and then add them up with sum based on number of parts ordered.<br />
<br />
I have no idea how to do this, any help would be awesome</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>mr_scooby</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread233667.html</guid>
		</item>
		<item>
			<title>Sql Query</title>
			<link>http://www.daniweb.com/forums/thread233609.html</link>
			<pubDate>Mon, 26 Oct 2009 21:23:01 GMT</pubDate>
			<description><![CDATA[Hello, 
Ihope to find some help in here, i have the following diagram  
 
[IMG]http://img143.imageshack.us/img143/6704/13503390.th.jpg[/IMG] (http://img143.imageshack.us/i/13503390.jpg/) 
 
and i want a query which return Emp_ID, Pro_ID  
 
note; 
i can get these values but by 2 queries as the...]]></description>
			<content:encoded><![CDATA[<div>Hello,<br />
Ihope to find some help in here, i have the following diagram <br />
<br />
<a rel="nofollow" class="t" href="http://img143.imageshack.us/i/13503390.jpg/" target="_blank"><a href="http://img143.imageshack.us/img143/6704/13503390.th.jpg" target="_blank">http://img143.imageshack.us/img143/6704/13503390.th.jpg</a></a><br />
<br />
and i want a query which return Emp_ID, Pro_ID <br />
<br />
note;<br />
i can get these values but by 2 queries as the following;<br />
 <pre style="margin:20px; line-height:13px">select Pro_ID from Projects where Dep_ID in <br />
(select Dep_ID from Departments where name = 'test') <br />
<br />
select Emp_ID from Employees where Dep_ID in <br />
<br />
(select Dep_ID from Departments where name = 'test')</pre><br />
the goal of having the result through one query is that i want to insert the value into another table<br />
insert into testTable (query)<br />
<br />
Hope to see reply ASAP</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>Moody1</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread233609.html</guid>
		</item>
		<item>
			<title>MS SQL</title>
			<link>http://www.daniweb.com/forums/thread233599.html</link>
			<pubDate>Mon, 26 Oct 2009 20:59:22 GMT</pubDate>
			<description>Can I get a template for Log in icon. I have purchased DB Name, MS SQL , Database connection. But I dont know how to connect my database file to server. 
BC PATTANAYAK</description>
			<content:encoded><![CDATA[<div>Can I get a template for Log in icon. I have purchased DB Name, MS SQL , Database connection. But I dont know how to connect my database file to server.<br />
BC PATTANAYAK</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>bcpattanayak</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread233599.html</guid>
		</item>
		<item>
			<title>Loop to generate future dates?!</title>
			<link>http://www.daniweb.com/forums/thread233515.html</link>
			<pubDate>Mon, 26 Oct 2009 16:23:29 GMT</pubDate>
			<description><![CDATA[What is the best way to generate a set of dates based on today's date? Essentially, what I wanna do is: 
1. Get Current Date 
2. Populate a table with future dates 6 months apart and go up until I reach, let's say, 12/31/2020 
 
I have looked at some of the date functions offered by MS-SQL 2005,...]]></description>
			<content:encoded><![CDATA[<div>What is the best way to generate a set of dates based on today's date? Essentially, what I wanna do is:<br />
1. Get Current Date<br />
2. Populate a table with future dates 6 months apart and go up until I reach, let's say, 12/31/2020<br />
<br />
I have looked at some of the date functions offered by MS-SQL 2005, but not quite sure how to run a loop. (I use ColdFusion as the front-end)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>cheapterp</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread233515.html</guid>
		</item>
		<item>
			<title>how can i find the table names</title>
			<link>http://www.daniweb.com/forums/thread233767.html</link>
			<pubDate>Mon, 26 Oct 2009 09:49:22 GMT</pubDate>
			<description>how can i find the table names from Sql server. what r the statement.</description>
			<content:encoded><![CDATA[<div>how can i find the table names from Sql server. what r the statement.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>else_harpal</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread233767.html</guid>
		</item>
		<item>
			<title>Importing xml into sql server 2008</title>
			<link>http://www.daniweb.com/forums/thread232967.html</link>
			<pubDate>Sat, 24 Oct 2009 17:32:59 GMT</pubDate>
			<description><![CDATA[Hi, 
 
I need a little help importing an XML file into sqlserver 2008.  I followed this example 
 
http://www.sql-server-performance.com/articles/dba/Loading_XML_data_into_SQL_Server_2008_p1.aspx 
 
(make sure you goto the rest of the pages in the article!) , generated the schema etc., but I can't...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I need a little help importing an XML file into sqlserver 2008.  I followed this example<br />
<br />
<a rel="nofollow" class="t" href="http://www.sql-server-performance.com/articles/dba/Loading_XML_data_into_SQL_Server_2008_p1.aspx" target="_blank">http://www.sql-server-performance.co...r_2008_p1.aspx</a><br />
<br />
(make sure you goto the rest of the pages in the article!) , generated the schema etc., but I can't get the import <br />
<br />
to do what I need. I was able to add the DataConversion on my own but I can't seem to figure out how to get both ID <br />
<br />
fields in the middle table.<br />
I made a simplified version.  For this example I have 3 tables.  Books, BookAuthors, Authors.<br />
<br />
Books Table (bookID, bookTitle, bookNumPages)<br />
BookAuthors Table (bookID, authorID)<br />
Authors (authorID, authorName)<br />
<br />
After the Import the tables should look like this<br />
Books<br />
79, Some Good Book, 300<br />
112, Another Book, 350<br />
BookAuthors<br />
79, 200<br />
79, 205<br />
79, 215<br />
112, 200<br />
Authors<br />
200, First Author<br />
205, Second Author<br />
215, Third Author<br />
<br />
The Problem I'm having is getting the BookID and AuthorID into the BookAuthors Table.  I'm just wondering if there <br />
<br />
is an easy way to set this up to Import or if I'm going to have to code it line by line.<br />
<br />
 <pre style="margin:20px; line-height:13px">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br />
&lt;result&gt;<br />
&nbsp; &nbsp; &lt;books&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;book&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;bookID&gt;79&lt;/bookID&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;bookTitle&gt;Some Good Book&lt;/bookTitle&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;bookNumPages&gt;300&lt;/bookNumPages&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;authors&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;author&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;authorID&gt;200&lt;/authorID&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/author&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;author&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;authorID&gt;205&lt;/authorID&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/author&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;author&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;authorID&gt;215&lt;/authorID&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/author&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/authors&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/book&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;book&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;bookID&gt;112&lt;/bookID&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;bookTitle&gt;Another Book&lt;/bookTitle&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;bookNumPages&gt;350&lt;/bookNumPages&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;authors&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;author&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;authorID&gt;200&lt;/authorID&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/author&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/authors&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/book&gt;<br />
&nbsp; &nbsp; &lt;/books&gt;<br />
&nbsp; &nbsp; &lt;authors&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;author&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;authorID&gt;200&lt;/authorID&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;authorName&gt;First Author&lt;/authorName&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/author&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;author&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;authorID&gt;205&lt;/authorID&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;authorName&gt;Second Author&lt;/authorName&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/author&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;author&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;authorID&gt;215&lt;/authorID&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;authorName&gt;Third Author&lt;/authorName&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/author&gt;<br />
&nbsp; &nbsp; &lt;/authors&gt;<br />
&lt;/result&gt;</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>dvprez</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread232967.html</guid>
		</item>
		<item>
			<title>sql +sql reporting service</title>
			<link>http://www.daniweb.com/forums/thread232376.html</link>
			<pubDate>Thu, 22 Oct 2009 17:35:12 GMT</pubDate>
			<description><![CDATA[Hi  
 
I developed report using sql server reporting service.I used parameter to assign value for sql query.I  want to use "LIKE" keyword in using parameter,How i do that?i wrote coding  below what u wrote before.I used @con as parameter. 
 
Select FriutID from Friut where friutName like'@con'%. ...]]></description>
			<content:encoded><![CDATA[<div>Hi <br />
<br />
I developed report using sql server reporting service.I used parameter to assign value for sql query.I  want to use &quot;LIKE&quot; keyword in using parameter,How i do that?i wrote coding  below what u wrote before.I used @con as parameter.<br />
<br />
 <pre style="margin:20px; line-height:13px">Select FriutID from Friut where friutName like'@con'%.</pre> <br />
Once I write above coding it gave me syntax error message.<br />
<br />
Thank<br />
Tank50</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>Tank50</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread232376.html</guid>
		</item>
		<item>
			<title>best wait to transpose all elements of a column into ColumnFields</title>
			<link>http://www.daniweb.com/forums/thread232337.html</link>
			<pubDate>Thu, 22 Oct 2009 15:44:10 GMT</pubDate>
			<description>Hello, 
 
I would like to know if there is an easy way to transform the following table 
 
			      CarId   | PropertyName    |  PropertyValue 
				   1      |   Size          |   XL   
				   1      |   Name          |   Porsche   
				   1      |   Color         |   Red   
				   2      |   Size ...</description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I would like to know if there is an easy way to transform the following table<br />
<br />
			      CarId   | PropertyName    |  PropertyValue<br />
				   1      |   Size          |   XL  <br />
				   1      |   Name          |   Porsche  <br />
				   1      |   Color         |   Red  <br />
				   2      |   Size          |   XS  <br />
				   2      |   Name          |   Smart  <br />
				   3      |   Name          |   Audi<br />
<br />
<br />
<br />
into <br />
<br />
			      CarId   |   Size  |     Name   |   Color<br />
				   1      |   XL    |   Porsche  |    Red<br />
				   2      |   XS    |   Smart    |				 <br />
				   3      |         |   Audi     |<br />
<br />
with MSSQL 2005 (i am using Studio Express)<br />
<br />
This a kind of crossTabling.<br />
<br />
until now here is what i am doing:<br />
<br />
I create a table why just 1 empty column (CarId)<br />
<br />
For each CarId, <br />
	I put the cardId in CarId Column<br />
	For each couple (PropertyName,PropertyValue)<br />
		i test whether the column 'PropertyName' exists. If no, i create it<br />
		then i put the 'PropertyValue' in the box (x='CardId',y='PropertyName')<br />
		<br />
		<br />
Thank you<br />
		<br />
		<br />
Julien</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>Julamotte</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread232337.html</guid>
		</item>
		<item>
			<title>Connection to remote server</title>
			<link>http://www.daniweb.com/forums/thread232266.html</link>
			<pubDate>Thu, 22 Oct 2009 10:43:28 GMT</pubDate>
			<description>I have multiple external databases that i want to connect to, from a stored procedure. What server the database is located on is dynamic (a record in a table). All of the external databases are LinkedServers, but also here i need to be able to define what server dynamicly. 
 
It works when i use...</description>
			<content:encoded><![CDATA[<div>I have multiple external databases that i want to connect to, from a stored procedure. What server the database is located on is dynamic (a record in a table). All of the external databases are LinkedServers, but also here i need to be able to define what server dynamicly.<br />
<br />
It works when i use EXEC to connect to the remote servers, example:<br />
 <pre style="margin:20px; line-height:13px">DECLARE @SQLinkedTable AS VARCHAR(50)<br />
DECLARE @SQL NVARCHAR(4000)<br />
DECLARE @Quantity AS INT<br />
<br />
SET @SQLinkedTable='LINKEDSERVER1.DB1.dbo'<br />
SELECT @SQL = 'SELECT @Quantity=COUNT(*) FROM '+@SQLinkedTable+'.[CampaignSettings] WHERE SQLID=1'<br />
EXEC sp_executesql @SQL, N'@Quantity INT OUTPUT', @Quantity OUTPUT</pre><br />
In this code it returns a count to me from the external database, but i whould like to to more than that, for example UPDATES from the current database, and i think making a cursor to loop all the records is a bit messy.<br />
<br />
These don't work: <br />
 <pre style="margin:20px; line-height:13px">DECLARE @SQLinkedTable AS VARCHAR(50)<br />
<br />
SET @SQLinkedTable='LINKEDSERVER1.DB1.dbo'<br />
SELECT * FROM @SQLinkedTable.[CampaignSettings])<br />
<br />
DECLARE @ExternalDB AS VARCHAR(200)<br />
SET @ExternalDB = 'Server=111.111.111.111;Database=DB1;UID=USR;Pwd=PASS;'<br />
SELECT * FROM OPENROWSET ('SQLNCLI',@ExternalDB, 'SELECT * FROM [CampaignSettings]')</pre><br />
I know that everyone says don't do dynamic table linking, but in this case i have no option.<br />
<br />
Any other Ideas?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>NextCom</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread232266.html</guid>
		</item>
		<item>
			<title>Best way to backup a database from one server to another server in SQL Server 2005</title>
			<link>http://www.daniweb.com/forums/thread231669.html</link>
			<pubDate>Tue, 20 Oct 2009 14:02:00 GMT</pubDate>
			<description>I need to know how and what steps to automate to backup a database on my production SQL server and restore that database in my test SQL server. The database exists in both servers currently. I want to set this up so it will run every day at a certain time. Does anyone know what I need to do for...</description>
			<content:encoded><![CDATA[<div>I need to know how and what steps to automate to backup a database on my production SQL server and restore that database in my test SQL server. The database exists in both servers currently. I want to set this up so it will run every day at a certain time. Does anyone know what I need to do for this.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>mldardy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread231669.html</guid>
		</item>
		<item>
			<title><![CDATA[Select only items that don't exist in another table]]></title>
			<link>http://www.daniweb.com/forums/thread231439.html</link>
			<pubDate>Mon, 19 Oct 2009 16:57:00 GMT</pubDate>
			<description><![CDATA[I want to select from a table only when a field repeats more than once.  For this I have: 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with...]]></description>
			<content:encoded><![CDATA[<div>I want to select from a table only when a field repeats more than once.  For this I have:<br />
<br />
 <pre style="margin:20px; line-height:13px">Select title, Count(*) As Cnt From poss_titles where Cnt &gt; 1 Group By Title Order By Cnt desc</pre><br />
But it says invalid column name cnt.  How should I refer to this dynamic field?<br />
Also, I only really want titles which dont exist in another table.  I believe a left join is required for this but I'm not too sure how to do it.<br />
Can anyone offer me some pointers?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>benkyma</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread231439.html</guid>
		</item>
		<item>
			<title>SELECT statement</title>
			<link>http://www.daniweb.com/forums/thread230835.html</link>
			<pubDate>Fri, 16 Oct 2009 23:40:20 GMT</pubDate>
			<description><![CDATA[I have a table for example: tb1 
with data: 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code Tags</a>...]]></description>
			<content:encoded><![CDATA[<div>I have a table for example: tb1<br />
with data:<br />
 <pre style="margin:20px; line-height:13px">cse-12m<br />
cse-343k<br />
cse-mka<br />
cse-ptu<br />
cse-jpy</pre><br />
How can I write a SELECT statement to retrieve data in one of these formats:<br />
1) cse-three digits number<br />
2) cse-p%<br />
<br />
and exclude other format data, any idea?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>michael123</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread230835.html</guid>
		</item>
		<item>
			<title>Need help on data addition</title>
			<link>http://www.daniweb.com/forums/thread230821.html</link>
			<pubDate>Fri, 16 Oct 2009 21:56:05 GMT</pubDate>
			<description><![CDATA[Hi,,.. Need hlpe on this. 
 
I have 2 columns Oldvalue and newvalue. I want to create a store procedure where the query will be as if oldvalue and new value have record, but both the records are not same then 'change' variable should increment by 1 for each computername, again if oldvalue is having...]]></description>
			<content:encoded><![CDATA[<div>Hi,,.. Need hlpe on this.<br />
<br />
I have 2 columns Oldvalue and newvalue. I want to create a store procedure where the query will be as if oldvalue and new value have record, but both the records are not same then 'change' variable should increment by 1 for each computername, again if oldvalue is having nullvalue and newvalue has record then 'add' variable should increment by 1 for each computername, same if oldvalue has record and newvalue has no record then 'remove' variable should increment by 1 for each computername. Also want to calculate the grantotal as shown below:<br />
<br />
example:<br />
<br />
name     add     change    remove    grand total<br />
abc          1           1             0                2  <br />
pqr          0           2             1                3  <br />
sdf          2            1             1               4     <br />
<br />
This was my first query<br />
My second query is I want to count the 'add' and 'remove' column as shown below from the above data only:<br />
<br />
add                         3<br />
remove                   2<br />
<br />
Kindly help me out to get out of this problem</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>Abhishek_Boga</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread230821.html</guid>
		</item>
		<item>
			<title>Small MSSQL problem</title>
			<link>http://www.daniweb.com/forums/thread230674.html</link>
			<pubDate>Fri, 16 Oct 2009 11:13:48 GMT</pubDate>
			<description><![CDATA[I'm using this piece of code to get the number of search results. However it says- Incorrect syntax near ')' (the very last ')'  ) 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>I'm using this piece of code to get the number of search results. However it says- Incorrect syntax near ')' (the very last ')'  )<br />
 <pre style="margin:20px; line-height:13px">SELECT COUNT(*) FROM<br />
(SELECT&nbsp; ID, ProductDescription FROM Products WHERE ProductDescription LIKE '%tech%')</pre>The inner select works fine and gives correct results, so I don't understand what's the problem... I won't be surprised if it's something stupid, but I've tried lots of things but with no success..<br />
So I hope you guys can give some hints.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>Wiizl</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread230674.html</guid>
		</item>
		<item>
			<title>mysql to mssql</title>
			<link>http://www.daniweb.com/forums/thread230610.html</link>
			<pubDate>Fri, 16 Oct 2009 05:48:18 GMT</pubDate>
			<description><![CDATA[hi, 
can any one tell me how to i use my sql sever's databse itno ms sql 2008 server. 
I tried to to do dat with the help of mysql backup file & execute it on ms sql server, but there are some syntax related problems. 
please help me. 
thanks in advance]]></description>
			<content:encoded><![CDATA[<div>hi,<br />
can any one tell me how to i use my sql sever's databse itno ms sql 2008 server.<br />
I tried to to do dat with the help of mysql backup file &amp; execute it on ms sql server, but there are some syntax related problems.<br />
please help me.<br />
thanks in advance</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>kool.net</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread230610.html</guid>
		</item>
		<item>
			<title>Convertion of Column name into Rows</title>
			<link>http://www.daniweb.com/forums/thread230384.html</link>
			<pubDate>Thu, 15 Oct 2009 12:23:37 GMT</pubDate>
			<description>I want to display the columns in to rows format as below: 
 
eg: _ col 1 _   _clo 2 _    
        yes      No 
 
I want this to display as: 
 
_Column name_ 
yes  
no</description>
			<content:encoded><![CDATA[<div>I want to display the columns in to rows format as below:<br />
<br />
eg: <span style="text-decoration:underline"> col 1 </span>   <span style="text-decoration:underline">clo 2 </span>   <br />
        yes      No<br />
<br />
I want this to display as:<br />
<br />
<span style="text-decoration:underline">Column name</span><br />
yes <br />
no <br />
<br />
The Code which i used as below:<br />
<br />
 <pre style="margin:20px; line-height:13px">set ANSI_NULLS ON<br />
set QUOTED_IDENTIFIER ON<br />
GO<br />
<br />
create PROCEDURE &#91;dbo&#93;.&#91;Vista_Capable&#93;&nbsp; &nbsp; &nbsp; &nbsp; <br />
AS&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
SET NOCOUNT ON;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
BEGIN<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Select 'Yes','No'<br />
End</pre></div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>Abhishek_Boga</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread230384.html</guid>
		</item>
		<item>
			<title>SQL Query is taking too much time</title>
			<link>http://www.daniweb.com/forums/thread230381.html</link>
			<pubDate>Thu, 15 Oct 2009 12:02:58 GMT</pubDate>
			<description><![CDATA[Hi,  
 
i have created a sp, that is taking too much time (more than 35 sec, is it more?). 
 
 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help...]]></description>
			<content:encoded><![CDATA[<div>Hi, <br />
<br />
i have created a sp, that is taking too much time (more than 35 sec, is it more?).<br />
<br />
<br />
<br />
 <pre style="margin:20px; line-height:13px">SELECT&nbsp; top 11 ROW_NUMBER() OVER (ORDER BY&nbsp; hjs_job_details.date_posted desc, KEY_TBL.RANK&nbsp; desc) <br />
AS Row, job_id,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
(case when len(job_title)&gt;59 then (substring(job_title,0,59)+'...') else job_title end ) as title,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
company_name as Source_Org, source_company_name as Org, jobdescription_url,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp;dbo.job_posted_on(hjs_job_details.date_posted) as date_posted, (short_desc+'...') as description,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
street, city, hjs_state.state_abbr as state, hjs_job_details.zipcode, company_url, hjs_job_details.state as job_state,hjs_job_details.crawledby&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
FROM hjs_job_details left outer join hjs_adv_source_type ha on hjs_job_details.source_type_id=ha.source_type_id&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
left outer join&nbsp; hjs_latlong on hjs_job_details.zipcode = hjs_latlong.zipcode&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
left outer join&nbsp; hjs_state on (hjs_job_details.state=hjs_state.state_abbr)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
left outer join&nbsp; hjs_service_campaign on (hjs_job_details.campaign_id = hjs_service_campaign.camp_id)<br />
INNER JOIN <br />
FREETEXTTABLE(hjs_job_details,(Job_title,short_desc,company_name),'nurse')&nbsp; &nbsp; &nbsp; &nbsp;  <br />
as KEY_TBL ON hjs_job_details.job_id = KEY_TBL.[KEY]&nbsp; where ( (1=1) <br />
and (dbo.udfn_Distance(29.6804,-82.3457,latitude,longitude) &lt;= 50 )<br />
and ( ( hjs_job_details.campaign_id is null )<br />
or (hjs_service_campaign.status &lt;&gt; 1) or ( dbo.CheckSponsordJobDailyBudget(job_id)=0)))&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
and((convert(datetime,convert(nvarchar,expiry_date,101))&gt;=convert(datetime,convert(nvarchar,getdate(),101)) OR expiry_date IS NULL)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
and (hjs_job_details.status=1 or hjs_job_details.status is null))</pre><br />
<br />
the line (dbo.udfn_Distance(29.6804,-82.3457,latitude,longitude) &lt;= 50 ) is taking too much time when we search in 70000 records.it is for finding distance between two lat/longs, i have checked function udfn_Distance, it is working fine.it is only taking time when it takes lat/longs for records.<br />
<br />
actually after calling this sp that 6 more sps are calling , so my page loading gets very slow, it take more than 5 mins to load full page with radius search.<br />
<br />
i want to make it fast.how can i do that.<br />
<br />
Please help me.<br />
<br />
Thanks,<br />
Ashish Pandey</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>ashu2409</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread230381.html</guid>
		</item>
		<item>
			<title>Help with the Following Logic</title>
			<link>http://www.daniweb.com/forums/thread230380.html</link>
			<pubDate>Thu, 15 Oct 2009 11:57:51 GMT</pubDate>
			<description><![CDATA[Good Day all  
 
it is Probably a long day, i cant think Straight now.  
 
i have a table that looks like this  
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680"...]]></description>
			<content:encoded><![CDATA[<div>Good Day all <br />
<br />
it is Probably a long day, i cant think Straight now. <br />
<br />
i have a table that looks like this <br />
<br />
 <pre style="margin:20px; line-height:13px">Nodeid&nbsp;  Parent&nbsp;  Description&nbsp; &nbsp;  Type&nbsp; &nbsp; &nbsp; Curr<br />
==========================================================================================<br />
89&nbsp; &nbsp; &nbsp; &nbsp;  NULL&nbsp; &nbsp;  Compulsory&nbsp; &nbsp; &nbsp; &nbsp; 1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  10<br />
90&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 89&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; B1052&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  10<br />
2820&nbsp; &nbsp; &nbsp; 89&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; One of&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  10<br />
<span style="color:red"><br />
4113&nbsp; &nbsp; &nbsp; &nbsp; 89&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; B1061&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  10</span><br />
2821&nbsp; &nbsp; &nbsp; &nbsp; 2820&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; B1054&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  10<br />
2822&nbsp; &nbsp; &nbsp; &nbsp; 2820&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; B1055&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  10</pre><br />
Now the Red Record needs to be on top of &quot;One of&quot; because the Parent is &quot;Compulsary&quot; with the &quot;Parent&quot; = 89. Now Even &quot;One of &quot; has the Same Parent as the red record but if its a &quot;One of &quot; and they have the same parent, then &quot;One of &quot;  must always be below the record. What i mean is that if there is a record with a same parent but different Type , the one that has type 2 should go below the one that has type 3 in my query. here is my query <br />
<br />
 <pre style="margin:20px; line-height:13px">select distinct nP.id, nP.NodeID, nP.parent, nP.Description, nRef.ID refParent, np.type <br />
&nbsp;from #Nodes nP<br />
left outer join #Nodes nRef on nP.Parent = nRef.NodeID&nbsp; &nbsp; &nbsp; &nbsp; -- look up the reference id of the parent<br />
order by&nbsp; refParent,nP.id,np.type desc</pre><br />
Thank you</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>vuyiswamb</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread230380.html</guid>
		</item>
		<item>
			<title>Communicating with MSSQL from Linux using PHP?</title>
			<link>http://www.daniweb.com/forums/thread229756.html</link>
			<pubDate>Tue, 13 Oct 2009 08:47:19 GMT</pubDate>
			<description><![CDATA[Hi, 
 
First of all, I'm no database expert. See me as managing a project where this problem occurs.  
 
We are building a system that will enable us to roll out Windows Patches automatically to all Windows systems we manage. We use WSUS on SQL Server 2005/SQL Express. The application will be part...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
First of all, I'm no database expert. See me as managing a project where this problem occurs. <br />
<br />
We are building a system that will enable us to roll out Windows Patches automatically to all Windows systems we manage. We use WSUS on SQL Server 2005/SQL Express. The application will be part of  our system monitoring tool, which in its turn runs on Linux using PHP Apache. <br />
<br />
The problem is we cannot communicate with SQL Server/WSUS using PHP from the Linux system. They can connect using telnet to the port. PHP however does not work. The developers told me they have searched the Internet, and found countless solutions for this problem. But none of the solutions work for them. So my question is: Has anyone wrestled with this problem, and solved it? <br />
<br />
TIA,<br />
Abel</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>MacAdam</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread229756.html</guid>
		</item>
		<item>
			<title>help with SQL query / view / count problem....</title>
			<link>http://www.daniweb.com/forums/thread229656.html</link>
			<pubDate>Tue, 13 Oct 2009 00:02:23 GMT</pubDate>
			<description><![CDATA[Greetings! I am hoping someone can help me with a MS SQL query/view problem. 
 
I am creating a "name my new baby" website where parents can upload a picture of their child and have  
 
users cast votes for a good name.  Users will see the child's photo and they will be able to "agree"  
 
with a...]]></description>
			<content:encoded><![CDATA[<div>Greetings! I am hoping someone can help me with a MS SQL query/view problem.<br />
<br />
I am creating a &quot;name my new baby&quot; website where parents can upload a picture of their child and have <br />
<br />
users cast votes for a good name.  Users will see the child's photo and they will be able to &quot;agree&quot; <br />
<br />
with a current suggested name or post their own suggested name.  I know most parents would rather name <br />
<br />
their own kid..this is just for fun to see what I can accomplish. :)<br />
<br />
So far I have two tables like this:<br />
<br />
Kids:<br />
kidID (int unique primary key)<br />
parentId (int..cross referenced to parents account)<br />
photoFile (varchar 25 characters referencing file photo)<br />
<br />
Votes:<br />
nameId (int unique primary key)<br />
suggestedName (varchar 15 characters)<br />
votescast (int...this counts how many votes each name has)<br />
<br />
What I would like is to have a &quot;masterlist&quot; page that shows a list of all current photos with the <br />
currently top voted name.  So if newborn.jpg has 25 votes for &quot;Sammy&quot; and littlecutie.jpg has 3 votes <br />
<br />
for &quot;Jessica&quot; my query would return the fields &quot;KidId, photoFile, suggestedName, VotesCast&quot; with the <br />
<br />
date being:<br />
<br />
5, redheadnewborn.jpg, &quot;Sammy&quot;, 25<br />
12, littlecutie.jpg, &quot;Jessica&quot;, 3<br />
<br />
I am only interested in seeing the top voted name for each photo.  I have tried a number of queries <br />
<br />
involving views...none of which seem to return what I want.<br />
<br />
I know this will probably involve the sql count function but I can't find an example that is close to what I want.  Any help would be very appreciated.   If it helps I am using MS SQL 2008.<br />
<br />
Thanks,<br />
J</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>jasperjerome</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread229656.html</guid>
		</item>
		<item>
			<title>Problem with keys</title>
			<link>http://www.daniweb.com/forums/thread229226.html</link>
			<pubDate>Sun, 11 Oct 2009 04:27:01 GMT</pubDate>
			<description><![CDATA[Hi, I have 2 tables that I have made using sql create table which seem to work ok until I try to insert data into the 2nd table then it throws a: didn't add 1 record due to key violations. 
 
When I use the design wizard and do exactly the same thing but without using sql it works fine. 
 
table 1...]]></description>
			<content:encoded><![CDATA[<div>Hi, I have 2 tables that I have made using sql create table which seem to work ok until I try to insert data into the 2nd table then it throws a: didn't add 1 record due to key violations.<br />
<br />
When I use the design wizard and do exactly the same thing but without using sql it works fine.<br />
<br />
table 1 sql- user table <br />
 <pre style="margin:20px; line-height:13px">CREATE TABLE User (<br />
userEmailAddress varChar(255) not null PRIMARY KEY, <br />
userFirstName varChar(100) not null,<br />
userLastName varChar(100),<br />
userStatus varChar(1) not null,<br />
userNickName varChar(40),<br />
userMifrenzPassword varChar(10) not null,<br />
UserEmailPassword varChar(10) not null,<br />
userDOB date<br />
)</pre>table 2 sql - email options table <br />
 <pre style="margin:20px; line-height:13px">CREATE TABLE Email_Options (<br />
emailNumber number not null PRIMARY KEY,<br />
userEmailAddress varChar(255) not null, <br />
emailProvider varChar(255) not null,<br />
popServerAddress&nbsp; varChar(255) not null,<br />
smtpServerAddress&nbsp; varChar(255) not null,<br />
popServerPort varChar(6) not null, <br />
smtpServerPort varChar(6) not null,<br />
FOREIGN KEY(userEmailAddress) references user(userEmailAddress)<br />
)</pre>have spent ages trying to find a solution and just don't know enough <br />
<br />
Like I said everything works ok when I do it using the design wizard and creating the relationships manually, however when I use sql I get exactly the same physical layout and view in the view and relationship view, except I get the cannot add record due to key violation.<br />
<br />
I get the message when updating the email options table, updating the user table works fine.<br />
<br />
Any ideas?? I'm lost :(</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>mr_scooby</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread229226.html</guid>
		</item>
		<item>
			<title>Count distinct values</title>
			<link>http://www.daniweb.com/forums/thread228839.html</link>
			<pubDate>Fri, 09 Oct 2009 10:50:51 GMT</pubDate>
			<description><![CDATA[I need to query a database of application titles and count the instances of each title.  I've already got a list<string> of distinct values from a previous query, and now I need to count how many times each value occurs.  I'm not sure if the query is correct, or how to handle the output.  So far I...]]></description>
			<content:encoded><![CDATA[<div>I need to query a database of application titles and count the instances of each title.  I've already got a list&lt;string&gt; of distinct values from a previous query, and now I need to count how many times each value occurs.  I'm not sure if the query is correct, or how to handle the output.  So far I have:<br />
<br />
 <pre style="margin:20px; line-height:13px">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
(cands is my list of distinct titles)<br />
&nbsp;for (int i = 0; i &lt; cands.Count; i++)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SqlCommand appCommand = new SqlCommand(&quot;select count(title) from poss_titles where title = @thisTitle&quot;, appConnection);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; appCommand.Parameters.AddWithValue(&quot;@thisTitle&quot;, cands[i]);<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SqlDataReader reader = appCommand.ExecuteReader();</pre><br />
I have created an 'AppTitle' class with getters and setters for 'name' and 'instances' so that I can return a List&lt;AppTitle&gt; from this method.  Maybe there is a better way than this?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>benkyma</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread228839.html</guid>
		</item>
		<item>
			<title>Stored procedure error</title>
			<link>http://www.daniweb.com/forums/thread228772.html</link>
			<pubDate>Fri, 09 Oct 2009 05:56:50 GMT</pubDate>
			<description><![CDATA[Hi to all , 
I am developing website in asp.net2.0 using VB. 
I wrote sored procedure, 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code...]]></description>
			<content:encoded><![CDATA[<div>Hi to all ,<br />
I am developing website in asp.net2.0 using VB.<br />
I wrote sored procedure,<br />
 <pre style="margin:20px; line-height:13px">ALTER PROCEDURE SELECTSC<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; (<br />
&nbsp; &nbsp; &nbsp; &nbsp; @cid INT<br />
&nbsp; &nbsp; &nbsp; &nbsp; )<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
AS<br />
BEGIN<br />
SELECT sc FROM collage_detail WHERE c_id=@cid<br />
END<br />
&nbsp; &nbsp; &nbsp; &nbsp; /* SET NOCOUNT ON */ <br />
&nbsp; &nbsp; &nbsp; &nbsp; RETURN</pre>and in vb I wrote on button click,<br />
 <pre style="margin:20px; line-height:13px">cmd.CommandType = CommandType.StoredProcedure<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmd.CommandText = &quot;SELECTSC&quot;<br />
'ot contains integer value<br />
Dim ot As Integer = op(i)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmd.Parameters.Add(&quot;@cid&quot;, SqlDbType.Int).Value = ot</pre><br />
while running application it gives me error that Function or procedure SELECTSC too many arguments specified.<br />
<br />
In collage_detail table I want value in sc column as per the c_id(collage id) . I will provide collage Id from array in while loop.<br />
because I want to check for 5 different collages.<br />
<br />
please give me any solution...!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>sakhi kul</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread228772.html</guid>
		</item>
		<item>
			<title>Padding Leading Zeroes to auo-increment INT column</title>
			<link>http://www.daniweb.com/forums/thread228645.html</link>
			<pubDate>Thu, 08 Oct 2009 19:32:54 GMT</pubDate>
			<description>I have a table in which I have an auto-increment int ID column. Can I set this column to pad the zeroes at the beginning so as to store them as, say, 0001 instead of 1, 0002 instead of 2, and so on? 
 
Subsequently, when the table reaches 10 entries, the ID should be 0010; on 100, it becomes 0100....</description>
			<content:encoded><![CDATA[<div>I have a table in which I have an auto-increment int ID column. Can I set this column to pad the zeroes at the beginning so as to store them as, say, 0001 instead of 1, 0002 instead of 2, and so on?<br />
<br />
Subsequently, when the table reaches 10 entries, the ID should be 0010; on 100, it becomes 0100. Implying that the number of zeroes to be padded does not always remain 3.<br />
<br />
The reason I wanna do this is because this auto-increment column is not the primary key column. Based on these integers, another column (which is the key) is to be updated such that the character triad of 'MLS' is concatenated to the int IDs like this:<br />
<br />
  ID	      MLSNumber<br />
0001	MLS0001<br />
0002	MLS0002<br />
0003	MLS0003<br />
.	           .<br />
.	           .<br />
.	           .<br />
etc.<br />
<br />
I am trying to setup a trigger for this concatenation process, but was wondering if there is an in-built way in SQL 2005 Express to pad the numbers rather than me having to do it. If not, what's the best way to proceed?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>SQL_n00b</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread228645.html</guid>
		</item>
		<item>
			<title>Select same column value and count</title>
			<link>http://www.daniweb.com/forums/thread228517.html</link>
			<pubDate>Thu, 08 Oct 2009 06:27:22 GMT</pubDate>
			<description><![CDATA[Guys,  
I need your help as I really can't seem to start on this query.I seem to not be able to come up with any logic. 
 
I have to create a query for a table. 
I have two tables in my DB . 
First one is a book table which consists of information about a book 
My table looks like following  
 
   ...]]></description>
			<content:encoded><![CDATA[<div>Guys, <br />
I need your help as I really can't seem to start on this query.I seem to not be able to come up with any logic.<br />
<br />
I have to create a query for a table.<br />
I have two tables in my DB .<br />
First one is a book table which consists of information about a book<br />
My table looks like following <br />
<br />
                  Table Book<br />
------------------------------------------------------------<br />
 book_id   | book_title   |  book_author<br />
-------------------------------------------------------------<br />
1              |   Abc             | Xyz<br />
2              |  Def              | Xyz<br />
3              | Ghi                | Xyz<br />
<br />
The other table is the transaction table which is used to issue books to a user<br />
<br />
                  Table Transaction<br />
------------------------------------------------------------<br />
  transaction_id   |   book_id   | transaction_date<br />
-------------------------------------------------------------<br />
   1                        |      2         |  XX-XX-XXXX <br />
   2                        |      1         |  XX-XX-XXXX<br />
   3                        |      1         |  XX-XX-XXXX<br />
   4                        |      3         |  XX-XX-XXXX<br />
   5                        |      2         |  XX-XX-XXXX<br />
   6                        |      2         |  XX-XX-XXXX<br />
   7                        |      1         |  XX-XX-XXXX<br />
   8                        |      2         |  XX-XX-XXXX<br />
<br />
<br />
Now the query which I need to make is to get the results of top issued books which means to display the books which have been issued the most or in other words been transacted the most (along the with the amount of times the book has been transacted).<br />
So that the result look like this <br />
----------------------------------------------------<br />
      Book_id            |   Times_Transacted  <br />
-----------------------------------------------------       <br />
        2                    |   4<br />
        1                    |   3<br />
        3                    |   1<br />
<br />
<br />
I would really appreciate any help on this.<br />
Cheers,<br />
Sushant</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>sushant17284</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread228517.html</guid>
		</item>
		<item>
			<title>Inserting multiple rows with 1 sql INSERT using ACCESS</title>
			<link>http://www.daniweb.com/forums/thread228509.html</link>
			<pubDate>Thu, 08 Oct 2009 05:54:33 GMT</pubDate>
			<description><![CDATA[hi guys, done heaps of googling and everything leads me to two outcomes.  
 
1. You can't do it 
 
2. You can do it this way  
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680"...]]></description>
			<content:encoded><![CDATA[<div>hi guys, done heaps of googling and everything leads me to two outcomes. <br />
<br />
1. You can't do it<br />
<br />
2. You can do it this way <br />
<br />
 <pre style="margin:20px; line-height:13px">INSERT INTO User(userEmailAddress, userFirstName,userLastName,userStatus,userNickName,userMifrenzPassword,userEmailPassword,userDOB)<br />
<br />
SELECT 'overthehill@gmail.com','Ben','Hill','U','benny','milk','soccer','20-10-2000'<br />
UNION ALL<br />
<br />
SELECT 'smithy@gmail.com','Tony','Smith','A','smithy','bread','rugby','20-11-1976'<br />
UNION ALL<br />
<br />
SELECT 'hotpants@gmail.com','Sarah','Jane','U','hotty','toast','netball','15-1-2000'<br />
UNION ALL<br />
<br />
SELECT 'traci@gmail.com','Traci','Hill','U','raisins','coffee','hockey','20-10-2000'<br />
UNION ALL<br />
<br />
SELECT 'lol@gmail.com','Ben','Johns','U','stubby','jam','rowing','10-2-2001'<br />
UNION ALL<br />
<br />
SELECT 'ss@gmail.com','Sarah','Smith','U','shorty','ham','running','5-5-2000'<br />
UNION ALL<br />
<br />
SELECT 'bob@gmail.com','Bob','Cawte','A','bob','eggs','bobsled','29-3-1980'</pre><br />
except it throws a  <br />
<br />
 <pre style="margin:20px; line-height:13px">Syntax error(misisng operator) in query expression &quot;20-10-2000&quot;<br />
UNION ALL<br />
<br />
SELECT 'smithy@gmail.com&quot;.</pre><br />
worst comes to worst I can use individual INSERT commands to demonstrate my database in class, but I have 40+ records for 2 tables so was trying to find a quicker way of doing it in two statements instead of 80.<br />
<br />
Anyone know if you can do this?<br />
<br />
cheers</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>mr_scooby</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread228509.html</guid>
		</item>
		<item>
			<title>How to write the If Condition in Stored Procedure</title>
			<link>http://www.daniweb.com/forums/thread228435.html</link>
			<pubDate>Wed, 07 Oct 2009 22:42:25 GMT</pubDate>
			<description><![CDATA[Hi... 
 
I want to write a IF Condition as follow: 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags" target="_blank">Help with Code...]]></description>
			<content:encoded><![CDATA[<div>Hi...<br />
<br />
I want to write a IF Condition as follow:<br />
<br />
 <pre style="margin:20px; line-height:13px">set ANSI_NULLS ON<br />
set QUOTED_IDENTIFIER ON<br />
GO<br />
Create PROCEDURE [dbo].[abc]&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
AS <br />
SET NOCOUNT ON;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
BEGIN&nbsp; &nbsp; &nbsp; <br />
<br />
Declare @add = 0 as int<br />
Declare @change = 0 as int<br />
Declare @remove = 0 as int<br />
<br />
Select&nbsp; abc.value as 'Name'<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  if (History.OLDSTR == '' and History.NEWSTR == <span style="font-weight:bold">value</span>) then <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  add++ as [Add]<br />
<br />
from History INNER JOIN MetaObjAttrRelations<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ON History.MetaObjAttrRelations_Idn = METAOBJATTRRELATIONS.METAOBJATTRRELATIONS_IDN<br />
<br />
End</pre> In the above code <span style="font-weight:bold">value</span> is present in the database. So how to write that column name in place of value. Im trying to create a procedure where there is old value and new value. If the old value has change or modified then <span style="font-weight:bold">change</span> variable will increment by 1, if there is no old value in the database and i have added new value in the databse then <span style="font-weight:bold">add</span> variable will increment by 1, if there is value in the old value and i have deleted the old value, then <span style="font-weight:bold">remove</span> variable will increment by 1.<br />
<br />
So kindly help me out to solve this issueee...</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>Abhishek_Boga</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread228435.html</guid>
		</item>
		<item>
			<title>FIle Format Problems</title>
			<link>http://www.daniweb.com/forums/thread228356.html</link>
			<pubDate>Wed, 07 Oct 2009 14:57:34 GMT</pubDate>
			<description><![CDATA[Good Day All 
 
I have a File Format Defined like this  
 
 
---Quote--- 
9.0 
4 
1       SQLCHAR       0      100       ","     0     ExtraField               "" 
2       SQLCHAR       0       100       ","    1     Descr            SQL_Latin1_General_CP1_CI_AS]]></description>
			<content:encoded><![CDATA[<div>Good Day All<br />
<br />
I have a File Format Defined like this <br />
<br />
<div style="margin:20px; margin-top:5px; "> <div class="smallfont" style="margin-bottom:2px">Quote:</div> <table cellpadding="5" cellspacing="0" border="0" width="100%"> <tr> <td class="alt2"> <hr />  9.0<br />
4<br />
1       SQLCHAR       0      100       &quot;,&quot;     0     ExtraField               &quot;&quot;<br />
2       SQLCHAR       0       100       &quot;,&quot;    1     Descr            SQL_Latin1_General_CP1_CI_AS<br />
3       SQLCHAR       0       100     &quot;,&quot;      2     ABREV             SQL_Latin1_General_CP1_CI_AS<br />
   <hr /> </td> </tr> </table> </div>and i use it like this <br />
<br />
 <pre style="margin:20px; line-height:13px">BULK INSERT dbo.TBL_CMPS FROM&nbsp; 'C:\\UNISA_IMPORT\\Final_Import\\Campuses.csv'<br />
WITH (<br />
&nbsp; &nbsp; &nbsp; FORMATFILE&nbsp; = 'C:\Format.DAT',<br />
&nbsp; &nbsp; &nbsp; FIELDTERMINATOR = ',',<br />
&nbsp; &nbsp; &nbsp; ROWTERMINATOR = '\n' );</pre><br />
<br />
and my Table Defination is like this <br />
<br />
 <pre style="margin:20px; line-height:13px">CREATE TABLE [dbo].[TBL_CMPS](<br />
&nbsp; &nbsp; &nbsp; &nbsp; [ID] [int] IDENTITY(1,1) NOT NULL,<br />
&nbsp; &nbsp; &nbsp; &nbsp; [DESCR] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,<br />
&nbsp; &nbsp; &nbsp; &nbsp; [ABREV] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL<br />
) ON [PRIMARY]<br />
<br />
GO<br />
SET ANSI_PADDING OFF</pre><br />
and my Error is <br />
<br />
<div style="margin:20px; margin-top:5px; "> <div class="smallfont" style="margin-bottom:2px">Quote:</div> <table cellpadding="5" cellspacing="0" border="0" width="100%"> <tr> <td class="alt2"> <hr />  Msg 4823, Level 16, State 1, Line 2<br />
Cannot bulk load. Invalid column number in the format file &quot;C:\Format.DAT&quot;.  <hr /> </td> </tr> </table> </div>Thank you</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>vuyiswamb</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread228356.html</guid>
		</item>
		<item>
			<title>query for proxy</title>
			<link>http://www.daniweb.com/forums/thread227996.html</link>
			<pubDate>Tue, 06 Oct 2009 09:20:02 GMT</pubDate>
			<description>Hi I like a query to check a proxy bid, wondering the best way around this, my tables are the product table holding the start bid and highest bid and a bidhistory table with all the bids, I use both idcustomer to check different bidders... appreciate the help.</description>
			<content:encoded><![CDATA[<div>Hi I like a query to check a proxy bid, wondering the best way around this, my tables are the product table holding the start bid and highest bid and a bidhistory table with all the bids, I use both idcustomer to check different bidders... appreciate the help.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>gsc1ugs</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread227996.html</guid>
		</item>
		<item>
			<title>access 2007 using CHECK</title>
			<link>http://www.daniweb.com/forums/thread227892.html</link>
			<pubDate>Mon, 05 Oct 2009 21:55:01 GMT</pubDate>
			<description><![CDATA[Was just wondering if anyone here is an Access master 
 
have this code that I want too add a CHECK too but keeps on throwing a syntax error  
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Was just wondering if anyone here is an Access master<br />
<br />
have this code that I want too add a CHECK too but keeps on throwing a syntax error <br />
<br />
 <pre style="margin:20px; line-height:13px">CREATE TABLE Email (<br />
userEmailAddress memo not null, <br />
timeDate datetime not null,<br />
contactEmailAddress memo not null,<br />
emailBoxType text(6) not null,<br />
readStatus binary(1) not null,<br />
subject text(255),<br />
message memo, <br />
primary key(userEmailAddress, timeDate),<br />
)</pre><br />
and this is the check <br />
<br />
 <pre style="margin:20px; line-height:13px">CHECK (readStatus 'Y' 'N')</pre><br />
have tried all sorts of combination's but just can't get it to work, have googled and copied exactly how they use it but still just throws a syntax error.<br />
<br />
Any help greatly appreciated.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>mr_scooby</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread227892.html</guid>
		</item>
		<item>
			<title>Query that Selects data from 3 tables in best way possible</title>
			<link>http://www.daniweb.com/forums/thread227832.html</link>
			<pubDate>Mon, 05 Oct 2009 16:05:55 GMT</pubDate>
			<description><![CDATA[Hey Everyone, 
 
So after weeks of torture, this things is near completion.  We're using SSRS to display the report on the .NET side.  However, I'm piecing together the last bits of the SQL query.  So, I have three tables.  One has names of all these buildings, one has contains reason_codes, and...]]></description>
			<content:encoded><![CDATA[<div>Hey Everyone,<br />
<br />
So after weeks of torture, this things is near completion.  We're using SSRS to display the report on the .NET side.  However, I'm piecing together the last bits of the SQL query.  So, I have three tables.  One has names of all these buildings, one has contains reason_codes, and the last one has three fields: building, reason code, extra_pay.<br />
<br />
The users need the report in a certain format.  For instance, on the left side, top to bottom, they want ALL the reason codes, on top from left to right, they want all the buildings (think of an excel type report).  Then, the extra_pay is shown where a reason code and building meet.<br />
<br />
Let's call the tables tblBuildings, tblReasonCodes, and tblMain.<br />
<br />
What would be the best way to return all this data?  Keep in mind that reason codes don't relate to buildings.  For instance, there is no mapping of building a to certain reason codes.  Any reason code can be applied to any building, and vice versa.  <br />
<br />
If I do a simple query like A (not complete), then for each building, I get every work reason code.  So if I have 10 buildings and 15 reason codes, then 10 * 15 = 150 rows.  I just need the ten buildings, the 15 codes, and my final data from tblMain mapped to it.<br />
<br />
Make sense?  Best way to do this, thanks :)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>Link82</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread227832.html</guid>
		</item>
		<item>
			<title>SQL Server+Microsoft Dynamics+FRx Reporting Server</title>
			<link>http://www.daniweb.com/forums/thread227751.html</link>
			<pubDate>Mon, 05 Oct 2009 10:19:18 GMT</pubDate>
			<description>how to install the FRx reporting server software and on which PC(SQL server PC or Application(Microsoft Dynamics PC)) and how to install on Server and how to install on client Mechines. 
 
 
An earlier response in this regard will be highly appreciated. 
 
Regards, 
 
Rashid Iqbal</description>
			<content:encoded><![CDATA[<div>how to install the FRx reporting server software and on which PC(SQL server PC or Application(Microsoft Dynamics PC)) and how to install on Server and how to install on client Mechines.<br />
<br />
<br />
An earlier response in this regard will be highly appreciated.<br />
<br />
Regards,<br />
<br />
Rashid Iqbal</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>rashid47010</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread227751.html</guid>
		</item>
		<item>
			<title>Equivalent of bTree in ms sql server</title>
			<link>http://www.daniweb.com/forums/thread227657.html</link>
			<pubDate>Mon, 05 Oct 2009 01:22:28 GMT</pubDate>
			<description>Hi, 
 
I have a table structure like this in mysql 
 
CREATE TABLE abcd ( 
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT, 
  `path` varchar(500) NOT NULL, 
  `tag` varchar(100) DEFAULT NULL, 
  `name` varchar(45) NOT NULL, 
  `type` int(10) unsigned NOT NULL,</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
I have a table structure like this in mysql<br />
<br />
 <pre style="margin:20px; line-height:13px">CREATE TABLE abcd (<br />
&nbsp; `id` int(10) unsigned NOT NULL AUTO_INCREMENT,<br />
&nbsp; `path` varchar(500) NOT NULL,<br />
&nbsp; `tag` varchar(100) DEFAULT NULL,<br />
&nbsp; `name` varchar(45) NOT NULL,<br />
&nbsp; `type` int(10) unsigned NOT NULL,<br />
&nbsp; PRIMARY KEY (`id`),<br />
&nbsp; KEY `SRCHINDEX` (`TAG`,`TYP`) USING BTREE<br />
)</pre><br />
How do I create the same table structure in microsoft sql server?<br />
<br />
Thanks</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>newtojsp</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread227657.html</guid>
		</item>
		<item>
			<title>How to generate a query where dynamic column name?</title>
			<link>http://www.daniweb.com/forums/thread227156.html</link>
			<pubDate>Fri, 02 Oct 2009 05:56:59 GMT</pubDate>
			<description>Hi guys,  
 
i am faced a problem here where is i need to select a query where the column name is dynamic: 
 
table a  
 
col1    |   col2 
---------------- 
A          |  Ali 
B          | Abu</description>
			<content:encoded><![CDATA[<div>Hi guys, <br />
<br />
i am faced a problem here where is i need to select a query where the column name is dynamic:<br />
<br />
table a <br />
<br />
col1    |   col2<br />
----------------<br />
A          |  Ali<br />
B          | Abu<br />
C          | Kawan<br />
A          |  Bayu<br />
B          | Cawam<br />
C          | didik<br />
<br />
how i write a query like below result?<br />
<br />
A         |           B           |            C<br />
Ali                   Abu                    Kawan<br />
Bayu              cawam                 didik<br />
<br />
<br />
Can anyone help?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>nokomoli</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread227156.html</guid>
		</item>
		<item>
			<title>SQL info log in event viewer</title>
			<link>http://www.daniweb.com/forums/thread227115.html</link>
			<pubDate>Thu, 01 Oct 2009 23:02:19 GMT</pubDate>
			<description><![CDATA[i am constantly receiving a 'failure audit' error 18456 state 14...login failed for user 'sa' on my sql 2005 server.  this is occurring every 5 minutes.  Can someone give me a direction on where to start?  I have checked several forums on the web, but none seem to lead me to the right direction...]]></description>
			<content:encoded><![CDATA[<div>i am constantly receiving a 'failure audit' error 18456 state 14...login failed for user 'sa' on my sql 2005 server.  this is occurring every 5 minutes.  Can someone give me a direction on where to start?  I have checked several forums on the web, but none seem to lead me to the right direction because i am not sure where to even start.  This is very annoying when my event log is filling up rather quickly.....ugh....  <br />
<br />
<br />
A little background history....had an old demo database that was continually growing but no one was using it.  Could these two things be related?  I had the company that installed the demo database also remove it and shortly after I was receiving these 18456 errors.  Please help....  <br />
Any help is greatly appreciated.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>didyouthink76</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread227115.html</guid>
		</item>
		<item>
			<title>import tab separated files im mssql 2005</title>
			<link>http://www.daniweb.com/forums/thread227093.html</link>
			<pubDate>Thu, 01 Oct 2009 19:57:11 GMT</pubDate>
			<description>Hi all, 
 
recently I had have to import a text file ( row are separated by TAB and each column by a space) into a new database. 
Here i will try to give example: 
 
this is how the text file looks 
...</description>
			<content:encoded><![CDATA[<div>Hi all,<br />
<br />
recently I had have to import a text file ( row are separated by TAB and each column by a space) into a new database.<br />
Here i will try to give example:<br />
<br />
this is how the text file looks<br />
<br />
LUA	25.614397	43.06958	261	0	1	7	0	57:51.8	0																																																																																																																							<br />
LUS	25.614397	43.06958	261	0	1	7	0	57:51.8	-1	400	284	5																																																																																																																				<br />
SEI	25.614397	43.06958	261	0	1	7	0	57:51.8	1																																																																																																																							<br />
CHI	25.614397	43.06958	261	0	1	7	0	57:51.8	12	1	10638	176194	400	3	320	5	640	2	640	-1	-1	-1	-1	1																																																																																																								<br />
NLIST	25.614397	43.06958	261	0	1	7	0	57:51.8	0	0																																																																																																																						<br />
RRCD	25.614397	43.06958	261	0	1	7	0	57:53.8	CCCH	event	30	EF	36	0	10	12	E5	8	5	1	90	0	8	87	18	7	83	3	49	D3	E0	4	F8	6A	10	0	14	21	67	F4	50	B1	E6	0A	42	67	4F	88	13	E3	A8	C0	0	51	89	9F	D1	42	C7	98	29	9	9D	3E	41	4F	96	A5	0	5	4A	36	7F	45	0B	1E	60	A4	26	74	F9	85	3E	7A	9C	0	15	32	0	1	81	E3	43	3C	0F	80	24	2	2B	B3	66	9	F0	2	40	22	3B	37	5C	A4	82	F0	51	4D	9	A7	F8	2	19	5A	85	40	40	FC	1	20	51	0<br />
<br />
This is how values must be imported:<br />
Column1          Col2                     Col3                Col4          Col5<br />
LUA                  25.614397          43.06958         261            0<br />
<br />
<br />
Could you give  me a clue how this could be done?<br />
thank you in advance,<br />
milenio</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>milenio</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread227093.html</guid>
		</item>
		<item>
			<title>Create Table from another Table</title>
			<link>http://www.daniweb.com/forums/thread226677.html</link>
			<pubDate>Wed, 30 Sep 2009 03:29:09 GMT</pubDate>
			<description>Hi, need help on coding. 
 
I would like to create a table from another table, including relationships/index/keys. 
 
I know I can do this: 
 
Create Table New_Table 
as (Select * from Old_Table) 
where 1=2</description>
			<content:encoded><![CDATA[<div>Hi, need help on coding.<br />
<br />
I would like to create a table from another table, including relationships/index/keys.<br />
<br />
I know I can do this:<br />
<br />
 <pre style="margin:20px; line-height:13px">Create Table New_Table<br />
as (Select * from Old_Table)<br />
where 1=2</pre><br />
<br />
but that would not include the relationships/index/keys. I wonder if it is possible to clone entirely by code. Many thanks.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>bellatrix77</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread226677.html</guid>
		</item>
		<item>
			<title>How to connect two tables</title>
			<link>http://www.daniweb.com/forums/thread226613.html</link>
			<pubDate>Tue, 29 Sep 2009 19:57:38 GMT</pubDate>
			<description>Hi all, 
i hope anyone of you can help me on the following matter: 
I have two tables: 
 
Recordingid	Connection	Sequenceno 
1233036621	1	3 
1233036621	1	4 
1233036621	2	8 
1233036621	2	9</description>
			<content:encoded><![CDATA[<div>Hi all,<br />
i hope anyone of you can help me on the following matter:<br />
I have two tables:<br />
<br />
Recordingid	Connection	Sequenceno<br />
1233036621	1	3<br />
1233036621	1	4<br />
1233036621	2	8<br />
1233036621	2	9<br />
<br />
And the second one:<br />
Recordingid	Connection	Sequenceno	Code	Cause<br />
1233036621	1	1	21	9<br />
1233036621	1	2	22	0<br />
1233036621	1	5	23	<br />
1233036621	2	6	21	9<br />
1233036621	2	7	22	0<br />
1233036621	2	10	23	<br />
<br />
What i need is to have this as a result<br />
<br />
Recordingid	Connection	Sequenceno	Code	Cause<br />
1233036621	1	1	21	9<br />
1233036621	1	2	22	0<br />
1233036621	1	3		<br />
1233036621	1	4		<br />
1233036621	1	5	23	<br />
1233036621	2	6	21	9<br />
1233036621	2	7	22	0<br />
1233036621	2	8		<br />
1233036621	2	9	<br />
1233036621	2	10	23<br />
<br />
(just to clarify: this is simply union between the two tables, but as from the second one  I need to take only 3 columns and from the first one 5 columns, so UNION of two separate queries does notwork / it needs the same number of columns in both queries/)<br />
<br />
Could any one give some ideas?<br />
<br />
Thank you in advance,<br />
milenio</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>milenio</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread226613.html</guid>
		</item>
		<item>
			<title>from clause issue</title>
			<link>http://www.daniweb.com/forums/thread226527.html</link>
			<pubDate>Tue, 29 Sep 2009 11:22:41 GMT</pubDate>
			<description><![CDATA[I have to select one table out of two to fetch data depending on particular condition i.e. month less than current month will fetch data from table *A* and month equals or greater than current month will fetch data from table *B* 
 
<FAKE SIGNATURE>]]></description>
			<content:encoded><![CDATA[<div>I have to select one table out of two to fetch data depending on particular condition i.e. month less than current month will fetch data from table <span style="font-weight:bold">A</span> and month equals or greater than current month will fetch data from table <span style="font-weight:bold">B</span><br />
<br />
&lt;FAKE SIGNATURE&gt;</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>javed123</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread226527.html</guid>
		</item>
		<item>
			<title>Anyway to use Having in this SQL STMT?</title>
			<link>http://www.daniweb.com/forums/thread226444.html</link>
			<pubDate>Tue, 29 Sep 2009 02:32:44 GMT</pubDate>
			<description><![CDATA[Hey everyone, 
 
I'm working on something ridiculously convoluted right now and am so close to finishing, hopefully I can get some proper help here. 
 
I have my base table, as so: 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a...]]></description>
			<content:encoded><![CDATA[<div>Hey everyone,<br />
<br />
I'm working on something ridiculously convoluted right now and am so close to finishing, hopefully I can get some proper help here.<br />
<br />
I have my base table, as so:<br />
 <pre style="margin:20px; line-height:13px">-- Insert statements for procedure here<br />
&nbsp; &nbsp; &nbsp; &nbsp; CREATE TABLE&nbsp; &nbsp; &nbsp; &nbsp; #starter<br />
&nbsp; &nbsp; &nbsp; &nbsp; (&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; emplid char(6),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; acct_code char(128),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; div&nbsp; &nbsp; &nbsp; &nbsp; char(3),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; payroll_sect char(3),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name varchar(128),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; work_loc int,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; week int,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hours_worked_in_a_week float, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hours_worked float,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mins_worked float, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; work_day_percentage float, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="font-weight:bold">time_code char(1), </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addtl_money float,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; city_code char(1),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std_hrs float, --what their stand. hrs are<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std_hrs_base float, --at what rate they'll start getting ot<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; date_worked datetime<br />
&nbsp; &nbsp; &nbsp; &nbsp; )</pre><br />
Yeah kind of big.  This is pretty much raw data in here. Depending on the time_code, a user gets different types of time: 1.0 hrs, 1.5 hrs (overtime 'O'), 2.0 (double 'D'), and Differential ('I') and so on.<br />
<br />
So depending on the time code, in a new temp table, I've been keeping track of what each employee has been earning (for a particular pay period).<br />
<br />
Things get tricky with the part-timers.  With part-timers, you have to see what their std hours are... they could be 10, 20, whatever (under 40).  The hours over which they start earning OT (1.5 hrs) is 40.  Each raw entry is also tagged to an acct_code.  So again, if a part-timer's std hrs are 30 and he puts in for 5 hours as 'Over time', sorry buddy, but you gotta hit 40 before earning 1.5 hrs.  So my system should take time_code like 'O', sum it, and put it under 1.0 hours.  Now if they mark 15 hours as 'O', then my system should put 10 under 1.0 hrs (now he's earned 40), so 5 hours goes under 1.5.<br />
<br />
For full-timers, it's not nearly as bad, I don't have to do the weekly check, because their standard hours are 40.<br />
<br />
Back to part-timers.  So the final table that holds the table is something like this:<br />
 <pre style="margin:20px; line-height:13px">CREATE TABLE #by_code<br />
(<br />
&nbsp; &nbsp; &nbsp; &nbsp; name varchar(128),<br />
&nbsp; &nbsp; &nbsp; &nbsp; emplid int,<br />
&nbsp; &nbsp; &nbsp; &nbsp; div int,<br />
&nbsp; &nbsp; &nbsp; &nbsp; work_loc int,<br />
&nbsp; &nbsp; &nbsp; &nbsp; payroll_sect int,<br />
&nbsp; &nbsp; &nbsp; &nbsp; acct_code varchar(100),<br />
&nbsp; &nbsp; &nbsp; &nbsp; _1_0_hrs float,<br />
&nbsp; &nbsp; &nbsp; &nbsp; _1_5_hrs float,<br />
&nbsp; &nbsp; &nbsp; &nbsp; _2_0_hrs float, <br />
&nbsp; &nbsp; &nbsp; &nbsp; _diff_hrs float,<br />
&nbsp; &nbsp; &nbsp; &nbsp; _eper_hrs float,<br />
&nbsp; &nbsp; &nbsp; &nbsp; _addtl_amt float<br />
)</pre>So far, the full-time cases work great.  I have to group by acct_code, because they need to see what type of hours are coming out of what type of acct_codes.<br />
<br />
Here is example sql code for a full-timer:<br />
 <pre style="margin:20px; line-height:13px">--step 1 1: for 40 hr custodians, 1.0 and 1.5, diff, eper, addtl amt is really easy!<br />
INSERT INTO&nbsp; &nbsp; &nbsp; &nbsp; #by_code (&nbsp; &nbsp; &nbsp; &nbsp; _1_0_hrs, _1_5_hrs, _eper_hrs,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; div, emplid, name, payroll_sect, acct_code&nbsp; &nbsp; &nbsp; &nbsp; )<br />
SELECT&nbsp; &nbsp; &nbsp; &nbsp; 0, SUM(CONVERT(decimal, hours_worked) + (CONVERT(decimal, mins_worked)/60)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + (dbo.workDayPercentageStringToDecimalUsingDivision(work_day_percentage) * (std_hrs_base/5))),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0, div, emplid, name, payroll_sect, acct_code<br />
FROM&nbsp; &nbsp; &nbsp; &nbsp; #starter<br />
WHERE&nbsp; &nbsp; &nbsp; &nbsp; std_hrs = std_hrs_base<br />
AND&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; time_code like 'O'<br />
GROUP BY&nbsp; &nbsp; &nbsp; &nbsp; acct_code, emplid, name, div, payroll_sect</pre><br />
My job is to do something similar for the part-timer.  I have to spit out proper 1.0 hrs and 1.5 hrs, <span style="font-weight:bold">depending on what they put in for the week.</span>  My problem is, if I do the weekly calculation, and two or more time_codes belong within a week, how do I keep track?<br />
<br />
I was doing something CRAZY like this:<br />
 <pre style="margin:20px; line-height:13px">INSERT INTO&nbsp; &nbsp; &nbsp; &nbsp; #by_code(&nbsp; &nbsp; &nbsp; &nbsp; _1_0_hrs, _1_5_hrs, _2_0_hrs, _diff_hrs, _eper_hrs, _addtl_amt,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; div, emplid, name, payroll_sect, acct_code )<br />
SELECT&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SUM(CONVERT(decimal, a.hours_worked) + (CONVERT(decimal, a.mins_worked)/60)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + (dbo.workDayPercentageStringToDecimalUsingDivision(a.work_day_percentage) * (a.std_hrs_base/5))),<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0, 0, 0, 0, 0, a.div, a.emplid, a.name, a.payroll_sect, a.acct_code<br />
FROM&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #starter a<br />
<br />
INNER JOIN&nbsp; &nbsp; &nbsp; &nbsp; #starter b<br />
ON&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a.emplid = b.emplid<br />
AND&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a.week = b.week<br />
HAVING&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (SUM(CONVERT(decimal, a.hours_worked) + (CONVERT(decimal, a.mins_worked)/60)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + (dbo.workDayPercentageStringToDecimalUsingDivision(a.work_day_percentage) * (a.std_hrs_base/5)))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt; (a.std_hrs_base - a.std_hrs))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
<br />
WHERE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a.std_hrs &lt; a.std_hrs_base<br />
and&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (a.time_code like 'R' or a.time_code like 'O')<br />
<br />
GROUP BY&nbsp; &nbsp; &nbsp; &nbsp; a.acct_code, a.emplid, a.name, a.div, a.payroll_sect</pre><br />
I have never used the having clause.  I have no idea how to and need to look it up some more.  Basically if part-timer (std_hrs &lt; std_hrs_base) and time_code is marked 'R' or 'O', given that in a week they've earned less than their std_hours_base (usually 40 hrs), then put all those hours in 1.0 and 0 for 1.5.  <br />
<br />
Can someone help me with this beast-like SQL (or it feels that way to me)?  I'm having a hard time breaking it up...<br />
<br />
Thanks.  Oh and feel free to ask any questions, it's kind of my bed time and I tried to put it all together, but sometimes that just isn't the case!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>Link82</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread226444.html</guid>
		</item>
		<item>
			<title>How can you update Datepart day</title>
			<link>http://www.daniweb.com/forums/thread226376.html</link>
			<pubDate>Mon, 28 Sep 2009 19:09:34 GMT</pubDate>
			<description><![CDATA[Hi does anyone know how to update a datepart? 
 
update table set datepart(dd, tablename) = '30' 
where ?? 
 
What I want to do is udpate records date data but only the day 
so where all of the records > '2009-07-25 00:00:00.000' 
are updated to 30 i.e. 2009-07-30, I want to leave the timestamp...]]></description>
			<content:encoded><![CDATA[<div>Hi does anyone know how to update a datepart?<br />
<br />
update table set datepart(dd, tablename) = '30'<br />
where ??<br />
<br />
What I want to do is udpate records date data but only the day<br />
so where all of the records &gt; '2009-07-25 00:00:00.000'<br />
are updated to 30 i.e. 2009-07-30, I want to leave the timestamp portion alone in the records. <br />
<br />
Thanks in advance. <br />
Sonia</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>sonial8</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread226376.html</guid>
		</item>
		<item>
			<title>HUGE table?!</title>
			<link>http://www.daniweb.com/forums/thread225846.html</link>
			<pubDate>Sat, 26 Sep 2009 00:01:26 GMT</pubDate>
			<description>I am using MS-SQL 2005 DB. One of the tables in the DB, that I inherited, has gotten upto 37000 records. And it will go up by another 50k records soon. Does that make too much data for one table? The table has about 25 columns, most of which contain VARCHAR type data.  
 
Also, since the DB acts as...</description>
			<content:encoded><![CDATA[<div>I am using MS-SQL 2005 DB. One of the tables in the DB, that I inherited, has gotten upto 37000 records. And it will go up by another 50k records soon. Does that make too much data for one table? The table has about 25 columns, most of which contain VARCHAR type data. <br />
<br />
Also, since the DB acts as a back-end to the web interface, would about 90k-100k records make the pages load slower? Since the web pages also include a 'search' functionality, every search will have to go through so many records at a time. In other words, what is the performance hit I will take for having so much data together?<br />
<br />
Am I being paranoid about the amount of data, or does something need to be done - and if I do, what are my options?<br />
<br />
Thanks!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>cheapterp</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread225846.html</guid>
		</item>
		<item>
			<title>MSSQL Server problem writing VARBINARY data.</title>
			<link>http://www.daniweb.com/forums/thread225832.html</link>
			<pubDate>Fri, 25 Sep 2009 22:46:54 GMT</pubDate>
			<description><![CDATA[I'm trying to INSERT a zip file into an MSSQL table. The table structure is such: 
 
  <div class="codeblock"> <div class="spaced"> <div style="float:right; margin-right:10px"> <a href="/forums/misc.php?do=explaincode&amp;TB_iframe=true&amp;height=400&amp;width=680" class="thickbox" title="Help with Code Tags"...]]></description>
			<content:encoded><![CDATA[<div>I'm trying to INSERT a zip file into an MSSQL table. The table structure is such:<br />
<br />
 <pre style="margin:20px; line-height:13px">CREATE TABLE [dbo].[zips](<br />
&nbsp; &nbsp; &nbsp; &nbsp; [id] [int] IDENTITY(1,1) NOT NULL,<br />
&nbsp; &nbsp; &nbsp; &nbsp; [timestamp] [varchar](50) NULL,<br />
&nbsp; &nbsp; &nbsp; &nbsp; [inserted] [varchar](50) NULL,<br />
&nbsp; &nbsp; &nbsp; &nbsp; [filename] [varchar](50) NULL,<br />
&nbsp; &nbsp; &nbsp; &nbsp; [raw_file] [varbinary](max) NULL<br />
) ON [PRIMARY]</pre>...nothing too fancy. <br />
<br />
When I insert a text file, everything is well and I'm able to retrieve the text content successfully without any problems, but when I insert a binary file such as zip, the binary data gets modified. <br />
<br />
My guess is that MSSQL somehow replaces the NON-PRINTABLE characters it gets to something default. <br />
<br />
The zip data I'm trying to insert is:<br />
<span style="font-weight:bold">0x504b0304140000080800715f303b607f</span>...<br />
<br />
but what ends up in the MSSQL table is (which is wrong):<br />
<span style="font-weight:bold">0x504B030414C080C0800808C080715F303B607F</span>...<br />
<br />
notice how the <span style="font-weight:bold">00</span>'s get replaced with <span style="font-weight:bold">C0 80</span><br />
<br />
text data in:<br />
<span style="font-weight:bold">0x<br />
2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a<br />
2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a<br />
2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a<br />
2a2a0d0a202050726f63657373696e672<br />
0536c6f74203d2031200d0a2a2a2a2a2a<br />
2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a<br />
2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a<br />
2a2a2a2a2a2a2a2a2a2a2a2a2a0d0a0d<br />
0a70617373776f726420414454524f</span><br />
<br />
text data out (which is correct):<br />
<span style="font-weight:bold">0x<br />
2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A<br />
2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A<br />
2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A<br />
2A2A0D0A202050726F63657373696E672<br />
0536C6F74203D2031200D0A2A2A2A2A2A<br />
2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A<br />
2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A<br />
2A2A2A2A2A2A2A2A2A2A2A0D0A0D<br />
0A70617373776F726420414454524F</span><br />
<br />
Any help will be greatly appreciated. I have zero experience with SQL, and I'm really struggling with this.  Thank you!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>LED555</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread225832.html</guid>
		</item>
		<item>
			<title>Help me (query join table)</title>
			<link>http://www.daniweb.com/forums/thread225574.html</link>
			<pubDate>Fri, 25 Sep 2009 03:13:50 GMT</pubDate>
			<description>Please Help me, 
 
I have 2 Table, A dan B. 
 
Table A : 
Sandar  |  jmlMuat 
--------------------------- 
Mirah    |  20 
Berlian  |  10</description>
			<content:encoded><![CDATA[<div>Please Help me,<br />
<br />
I have 2 Table, A dan B.<br />
<br />
Table A :<br />
Sandar  |  jmlMuat<br />
---------------------------<br />
Mirah    |  20<br />
Berlian  |  10<br />
<br />
Table B :<br />
Sandar  | jmlBongkar<br />
-------------------------------<br />
Mirah    | 30<br />
Nilam    | 15<br />
<br />
I want to join that table to get result like this :<br />
Sandar  |  jmlMuat  |  jmlBongkar<br />
-------------------------------------------------<br />
Mirah    |  20          |  30<br />
Nilam    |  Null        |  15<br />
Berlian  |   10         |  Null<br />
<br />
I try Query :<br />
SELECT A.Sandar, A.jmlBongkar, B.jmlMuat<br />
FROM   A full JOIN B<br />
ON A.Sandar = B.Sandar<br />
<br />
but the result is :<br />
<br />
Sandar  |  jmlMuat  |  jmlBongkar<br />
-------------------------------------------------<br />
Mirah    |  20          |  30<br />
Null       |  Null        |  15<br />
Berlian  |   10         |  Null<br />
<br />
why &quot;Nilam&quot; replace by &quot;Null&quot; ??<br />
<br />
Whats wrong with my query?<br />
<br />
Please correct my query so i get the result i want.<br />
<br />
Thx.<br />
<br />
Yusuf.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>josh_keren</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread225574.html</guid>
		</item>
		<item>
			<title>Stored Procedure - Can CREATE but not EXECUTE</title>
			<link>http://www.daniweb.com/forums/thread225241.html</link>
			<pubDate>Wed, 23 Sep 2009 20:13:37 GMT</pubDate>
			<description><![CDATA[The title to the thread pretty much describes what I am getting stuck at. I was able to create a procedure successfully, but everytime I try to execute it, I get an error: 
---Quote--- 
The EXECUTE permission was denied on the object 'sp_OACreate', database 'mssqlsystemresource', schema 'sys'....]]></description>
			<content:encoded><![CDATA[<div>The title to the thread pretty much describes what I am getting stuck at. I was able to create a procedure successfully, but everytime I try to execute it, I get an error:<div style="margin:20px; margin-top:5px; "> <div class="smallfont" style="margin-bottom:2px">Quote:</div> <table cellpadding="5" cellspacing="0" border="0" width="100%"> <tr> <td class="alt2"> <hr />  The EXECUTE permission was denied on the object 'sp_OACreate', database 'mssqlsystemresource', schema 'sys'.  <hr /> </td> </tr> </table> </div>Logically speaking, if the DB admin has granted me permission to create SPs, wouldn't he have granted me permission to execute them too? Below is how I am calling the SP:<br />
 <pre style="margin:20px; line-height:13px">USE [myDBName]<br />
GO<br />
<br />
DECLARE&nbsp; &nbsp; &nbsp; &nbsp; @return_value int<br />
<br />
EXEC&nbsp; &nbsp; &nbsp; &nbsp; @return_value = [dbo].[sp_SMTPMail]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @SenderName = N'John',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @SenderAddress = N'johndoe@example.com',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @RecipientName = N'Jane',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @RecipientAddress = N'janedoe@example.com',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Subject = N'Test SP Execution',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Body = N'Testing 1-2-3',<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @MailServer = N'smtp.example.com'<br />
<br />
SELECT&nbsp; &nbsp; &nbsp; &nbsp; 'Return Value' = @return_value<br />
<br />
GO</pre>(Of course, all the values above - including the MailServer attribute - are fake)<br />
<br />
How do I get around this? Am using MS SQL Server 2005<br />
<br />
Thanks!</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>SQL_n00b</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread225241.html</guid>
		</item>
		<item>
			<title>Deadlocked on lock problem in sql with multithreading</title>
			<link>http://www.daniweb.com/forums/thread225033.html</link>
			<pubDate>Wed, 23 Sep 2009 06:40:47 GMT</pubDate>
			<description>Hi, 
 
i have created a window service with multithreading, but getting many deadlocks on sql in one Stored procedure when i start this service,and after that service does not do anything but in idle mode. 
 
the details of exception is below. 
 
Error :Wednesday, September 23, 2009  2:22:58 AM...</description>
			<content:encoded><![CDATA[<div>Hi,<br />
<br />
i have created a window service with multithreading, but getting many deadlocks on sql in one Stored procedure when i start this service,and after that service does not do anything but in idle mode.<br />
<br />
the details of exception is below.<br />
<br />
Error :Wednesday, September 23, 2009  2:22:58 AM<br />
Method:UPD_CrawlerLastUrl<br />
    1.   Transaction (Process ID 68) was deadlocked on lock | communication buffer resources with another process and has been chosen as the deadlock victim. Rerun the transaction.<br />
    2.      at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)<br />
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)<br />
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)<br />
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)<br />
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)<br />
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)<br />
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)<br />
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)<br />
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()<br />
   at HJS_CrawlerService.Class.clsDB.UPD_CrawlerLastUrl(String url, Int32 xml_id, Int64 curpage, String page_counter, String thread_id, String keyword, Int32 last_url_count)<br />
    3.   .Net SqlClient Data Provider<br />
==============================================================================================================<br />
<br />
<br />
Pleae help me...<br />
<br />
<br />
Thanks,<br />
Ashish Pandey</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>ashu2409</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread225033.html</guid>
		</item>
		<item>
			<title>Is it logical to change SQL  permissions from 3rd party app?</title>
			<link>http://www.daniweb.com/forums/thread224598.html</link>
			<pubDate>Mon, 21 Sep 2009 12:59:10 GMT</pubDate>
			<description><![CDATA[Hi, 
recently i needed to query a table , however i was denied "Select " permissions (because permissions had not yet been exported as the db was). 
Should my application enable for administrator to grant permissions , if that error occurs OR should permission granting be done through MS SQL server...]]></description>
			<content:encoded><![CDATA[<div>Hi,<br />
recently i needed to query a table , however i was denied &quot;Select &quot; permissions (because permissions had not yet been exported as the db was).<br />
Should my application enable for administrator to grant permissions , if that error occurs OR should permission granting be done through MS SQL server only?<br />
(is it unnecessary,security risk or good practice?)<br />
<br />
-Thanks :icon_mrgreen:</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>stoymigo</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread224598.html</guid>
		</item>
		<item>
			<title>query order problem</title>
			<link>http://www.daniweb.com/forums/thread224555.html</link>
			<pubDate>Mon, 21 Sep 2009 09:54:10 GMT</pubDate>
			<description><![CDATA[Hii 
I Have Facing with Order problem 
i try to query From Table 
 
it go like this -> 
SELECT * FROM Client 
WHERE (ClientName LIKE 'X%') OR (ClientName LIKE '%[ ]X%') 
It mean give me all clients that start Whit X Letter And Included MiddleName If There is And Last Name. but With Out Ordering!! 
...]]></description>
			<content:encoded><![CDATA[<div>Hii<br />
I Have Facing with Order problem<br />
i try to query From Table<br />
<br />
it go like this -&gt;<br />
 <pre style="margin:20px; line-height:13px">SELECT * FROM Client<br />
WHERE (ClientName LIKE 'X%') OR (ClientName LIKE '%&#91; &#93;X%')</pre><br />
It mean give me all clients that start Whit X Letter And Included MiddleName If There is And Last Name. but With Out Ordering!!<br />
<br />
And i need to Order it!!<br />
first by Name after it by MiddleName and by LastName...<br />
<br />
for example -&gt; ClientName<br />
Erorn Mikel Bon Joi<br />
Jack clint cary<br />
Erorn Mikel Bon Jacov<br />
mohamd abo jaml habdalhaa<br />
jaber mahmoud ben saber<br />
<br />
now query all names that Start With 'J'!<br />
<br />
result need to look like this<br />
1. Jack clint cary<br />
2. jaber mahmoud ben saber<br />
3. mohamd abo jaml habdalhaa<br />
4. Erorn Mikel Bon Jacov<br />
5. Erorn Mikel Bon Joi<br />
<br />
i don't know how to order it,<br />
Someon Have an idea how to start ?<br />
<br />
eyal.c</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>eeyc</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread224555.html</guid>
		</item>
		<item>
			<title>Putting OPTIONAL condition in where clause for select statement</title>
			<link>http://www.daniweb.com/forums/thread224328.html</link>
			<pubDate>Sun, 20 Sep 2009 04:27:09 GMT</pubDate>
			<description><![CDATA[Hey Guys, 
 
So I'm working on an ASP page and I am making use some select statement. Now, I need to specify a where clause and make the only condition in there optional, i.e.: 
 
 
SELECT * from table where Upper(name) LIKE "SID" 
 
I want to make]]></description>
			<content:encoded><![CDATA[<div>Hey Guys,<br />
<br />
So I'm working on an ASP page and I am making use some select statement. Now, I need to specify a where clause and make the only condition in there optional, i.e.:<br />
<br />
 <pre style="margin:20px; line-height:13px">SELECT * from table where Upper(name) LIKE &quot;SID&quot;</pre><br />
I want to make <br />
<br />
 <pre style="margin:20px; line-height:13px">where Upper(name) LIKE &quot;SID&quot;</pre><br />
optional here. That is if, I pass &quot;SID&quot;, it does the where clause, other wise it just does a select.<br />
<br />
Any suggestions?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>sid78669</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread224328.html</guid>
		</item>
		<item>
			<title>Please help me in  getting maximum sales in their own region by sql query</title>
			<link>http://www.daniweb.com/forums/thread224249.html</link>
			<pubDate>Sat, 19 Sep 2009 14:29:15 GMT</pubDate>
			<description>Please help me in  getting maximum sales in their own region by sql query</description>
			<content:encoded><![CDATA[<div>Please help me in  getting maximum sales in their own region by sql query</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>manips</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread224249.html</guid>
		</item>
		<item>
			<title>SQL Express 2008</title>
			<link>http://www.daniweb.com/forums/thread224090.html</link>
			<pubDate>Fri, 18 Sep 2009 19:25:39 GMT</pubDate>
			<description><![CDATA[I'm so completely new at trying run a local SQL server that it's laughable to watch me try.  
 
Anyhow, I made the install to my laptop and it seemed to go okay with no errors or anything like that. When I look in the configuration manager it says that SQL Server is running and that I'm connected...]]></description>
			<content:encoded><![CDATA[<div>I'm so completely new at trying run a local SQL server that it's laughable to watch me try. <br />
<br />
Anyhow, I made the install to my laptop and it seemed to go okay with no errors or anything like that. When I look in the configuration manager it says that SQL Server is running and that I'm connected as 'LocalSystem'. When I try to connect in the Server Management Studio for Server Name it finds the name of my laptop in 'Network Servers' I would think it should be under 'Local', No? When i try to connect I get an error along the lines of 'Network related or Instance-Specific' error. Any ideas how to straighten this out? <br />
<br />
Also, What I really want to do is make a fresh install on my desktop computer to act as the server and use the external drive on that machine to store my db info. Any tips how to set it up without making a royal mess of it like i did on this machine? <br />
<br />
Any help is greatly appreciated.</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>CFROG</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread224090.html</guid>
		</item>
		<item>
			<title>View composed of partitioned tables</title>
			<link>http://www.daniweb.com/forums/thread224009.html</link>
			<pubDate>Fri, 18 Sep 2009 13:04:41 GMT</pubDate>
			<description><![CDATA[Hello, 
 
I am thinking of using a partitioned view in my database but i am not being able to find  whether it will affect other normal views i.e. if i have a view 'A' consisting of many tables/views and then i partitioned one of the tables into several tables joined by a partitioned view 'B',...]]></description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I am thinking of using a partitioned view in my database but i am not being able to find  whether it will affect other normal views i.e. if i have a view 'A' consisting of many tables/views and then i partitioned one of the tables into several tables joined by a partitioned view 'B', would that effect the performance of the original view 'A'?</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>joewazen</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread224009.html</guid>
		</item>
		<item>
			<title>Cast Varchar to decimal detecting alpha chars first</title>
			<link>http://www.daniweb.com/forums/thread223977.html</link>
			<pubDate>Fri, 18 Sep 2009 08:46:17 GMT</pubDate>
			<description><![CDATA[Hi all hopefully I can explain my problem correctly, this is my first post on DaniWeb. 
 
I'm currently working on a legacy medical research database that uses a Varchar field to store a decimal number,  this field can also be used to store text entered by a researcher on the paper form used to...]]></description>
			<content:encoded><![CDATA[<div>Hi all hopefully I can explain my problem correctly, this is my first post on DaniWeb.<br />
<br />
I'm currently working on a legacy medical research database that uses a Varchar field to store a decimal number,  this field can also be used to store text entered by a researcher on the paper form used to populate the database.<br />
<br />
I'm currently producing reporting views on this database and I need to find a way to detect alpha characters in the variable and return null if a decimal number is not the only thing in the string.<br />
<br />
I need to use this value to calculate minimum, maximum and average values by casting or converting it.<br />
<br />
the following example works for null values and empty strings, I just need to test for any alpha chars before i allow cast to change the value to a decimal.<br />
<br />
 <pre style="margin:20px; line-height:13px">select case when (HbA1c_perc is NULL) or (HbA1c_perc = '') then <br />
&nbsp; &nbsp; &nbsp; &nbsp; NULL <br />
else <br />
&nbsp; &nbsp; &nbsp; &nbsp; cast(HbA1c_perc as decimal(8,2)) <br />
end as HbA1c_perc<br />
from clinical</pre><br />
<br />
thanks in advance for any help you can give me.<br />
<br />
:)</div> ]]></content:encoded>
			<category domain="http://www.daniweb.com/forums/forum127.html">MS SQL</category>
			<dc:creator>normmy</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/forums/thread223977.html</guid>
		</item>
	</channel>
</rss>
