User Profile
Collapse
-
My pleasure. It's great to know that even after six years these posts are helpful for someone :). -
It means that you are connecting to SQL Server 2000, not SQL Server 2008.
SQL Server 2000 does not allow you to add multiple rows using "insert...value s" command, so you should use approach suggested by ck9663Leave a comment:
-
Do you connect to SQL Server 2008?
To verify the version of SQL Server you are connected to run the following query:
Code:print @@version
Code:select compatibility_level from sys.databases where database_id=db_id()
Leave a comment:
-
santhanalakshmi , your original script is absolutely correct for SQL Server 2008, but not for SQL Server 2000.
Inserting multiple rows using "insert...value s" command is one of new features of SQL Server 2008Leave a comment:
-
Have you looked at sample I provided? It demonstrates how to synchronize data from two different databases in more efficient way than you do.
----
Concerning your particular problem with
IF @BlasterID <> (select BlasterID from Blasters ):
You can compare a variable (@BlasterID) with resultset (select BlasterID from Blasters) only when resultset contains a single row with single column. In your case resultset contains...Leave a comment:
-
;with Ordered(temp_va lue, Position) as
(
select temp_value, Position = row_number()
over(order by temp_date desc)
from temp_sensor_tab le
where device_id = '1'
)
select @temp_value = temp_value
from Ordered
where Position = 1Leave a comment:
-
You don't need cursors for this purpose. Please look at following sample that demonstrates how you should synchronize your data:
create database temp
create database temp1
go
create table temp.dbo.mine(i d int identity, name nvarchar(max))
create table temp1.dbo.mine( id int identity, name nvarchar(max))
insert temp.dbo.mine(n ame) values('Updated Value1')
insert temp.dbo.mine(n ame) values('Updated Value2')...Leave a comment:
-
Code:;with Ordered(temp_value, Position) as ( select temp_value, Position = row_number() over(order by temp_date desc) from temp_sensor_table where device_id = @device_id_temp ) select temp_value from Ordered where Position = 1
Leave a comment:
-
SQL Server 2005 solution (don't forget to replace YOUR_FIELDS_HER E with correct field list, ORDER_FIELD with correct field name):
Code:;with Ordered(YOUR_FIELDS_HERE, Position) as ( select YOUR_FIELDS_HERE, Position = row_number() over(partition by segmentcode order by ORDER_FIELD) from t_security where segmentcode in( 'AIM','AIM3','AIMI','AMSM','ASQ1','ASQ2','ASX1','A SX2','ASXN','CIBB','CNVE','CRNR','CRTR','CSEQ','CS
Leave a comment:
-
Uniqueidentifie r type (also called GUID, "Globally Unique IDentifier") have a standard text representation of "8chars-4chars-4chars-4chars-12chars", where each character is a hexadecimal digit (0-9, A-F). See GUID for more information....Leave a comment:
-
SQL Server 2005 introduces a number of new keywords that make full compatibility impossible (because your code may use these keywords as cursor identifiers, etc.). If you want to be sure your queries are 100% compatible, set the compatibility level for your database to "8.0"Leave a comment:
-
The query posted by helloiamhere is just a sample of how you should refer to different databases.
StudentList and CourseSelection are DATABASE namesLeave a comment:
-
Please describe what actions did you take to find out the problem, because it looks like as soon as you encounter an error you post it here instead trying to understand it. Previous one was just because of incorrect order of clauses in the SELECT statement, and it can be easily figured out from Books Online.
Concerning your current problem: there is nothing wrong with your query (except if you have case-sensitive collation), you may...Leave a comment:
-
CREATE FUNCTION dbo.CountofUser s()
RETURNS TABLE
AS RETURN
SELECT Count(*) AS CountOfID, forum.partID
FROM forum
WHERE forum.partID<>0
GROUP BY forum.partIDLeave a comment:
-
[CODE=sql]SELECT A.AGENT_CODE,T. AGENT_ID,Count (T.TRANS_ACTION _ID), Sum (T.amt_dls),A.r elationship_fro m
FROM TRANSACTION_TAB LE T inner join
AGENT A (NOLOCK) on T.agent_id = A.agent_id
WHERE
t.DOT between A.relationship_ from and dateadd(dd, 90, A.relationship_ from)
AND promoter_region = 'SC'
AND promoter_center = '4'
--AND T.AGENT_ID = '460'...Leave a comment:
-
Please specify the SQL Server version, solutions may be completely different for MSSQL 2000 and MSSQL 2005:
SQL 2005-only solution:
Code:declare @t table (Date datetime, ID int, Balance int, primary key (ID, Date)) insert @t select Date='2007-1-1', ID=1, Balance=400000 union all select '2006-1-1', 1, 700000 union all select '2005-1-1', 1, 100000 union all select '2007-1-1', 2, 400000
Leave a comment:
-
-
Ooops, forgot to add parentheses. Should be:
CREATE FUNCTION dbo.CountofUser s()
RETURNS TABLE
AS RETURN
SELECT Count(*) AS CountOfID, forum.partID
FROM forum
GROUP BY forum.partID
WHERE forum.partID<>0
Usage:
FROM (forum LEFT JOIN Countofusers() as CountOfUsers ON forum.ID = CountOfUsers.Pa rtID) INNER JOIN NumberPosts ON forum.author = Number...Leave a comment:
-
SQL Server 2005 allows you to specify variable in TOP clause (previous versions don't allow it). So you have to:
1. evaluate the number of rows and assign it to variable
2. run SELECT TOP (@YourVariable) ... from ......Leave a comment:
-
This forum is dedicated to SQL Server problems, not to NetWeaver.
Please refer to corresponding forums/tech support: https://www.sdn.sap.com/irj/sdn/indexLeave a comment:
No activity results to display
Show More
Leave a comment: