|
Did you unblock port 1433?
|
|
|
|
|
That did the job. Thanks very much.
|
|
|
|
|
That's very old, very widespread common knowledge. You could have found it on Google in about 10 seconds rather than asking here in the lounge.
"It's so simple to be wise. Just think of something stupid to say and then don't say it."
-Sam Levenson
|
|
|
|
|
Are you using Sql 2005? if yes, you may need to set up an alias in Sql configuration manager for the server you try to connect.
TOMZ_KV
|
|
|
|
|
Hi,
I have One SP in Sql Server 2005.In that SP i need to get the IP number of the Local System. Can anyone tell me How?
thanks in Advance
sri
|
|
|
|
|
Member 4008492 wrote: IP number of the Local System
Local system ? You won't get IP address in a Stored Procedure. You can pass it as a parameter from outside.
|
|
|
|
|
If this is only internal network you can use SELECT HOST_NAME() giving you the name of the computer. You could then create a CLR proc to get the IP.
|
|
|
|
|
We have a data feed where we need the authors name description and then all the videos the author made.
I created a table DataFeed (authorId int, name, desc, items xml). I then filled it with all the authors names and descriptions.
I need the items to look like this
"Author"Author Name 1"/Author"
"Item"Video1"/Item"
"Item"Video2"/Item"
"Author"Author Name 2"/Author"
"Item"Video1"/Item"
"Item"Video2"/Item"
"Item"Video3"/Item"
I have a FOR XML query that leoinfo gave me yesterday where I query all videos for a author but when I tried the following I cant get the output because it needs a variable in the query to output to a OUTPUT var....
DECLARE @xml xml
DECLARE @cmd nvarchar(4000)
DECLARE @AuId int
DECLARE @AuName varchar(50)
DECLARE cur_author CURSOR FOR
SELECT AuthorId, AuthorName FROM dbo.DataFeed
OPEN cur_author
FETCH NEXT FROM cur_author INTO @AuId,@AuName
WHILE @@FETCH_STATUS = 0
BEGIN
SET @cmd = [SQL FOR XML Query Videos WHERE AuthorId = @AuId]
EXEC sp_executesql @cmd, @xml OUTPUT
UPDATE dbo.DataFeed SET items = @xml WHERE WHERE AuthorId = @AuId
FETCH NEXT FROM cur_author INTO @AuId,@AuName
END
..
here is the SQL FOR XML Query
'WITH XMLNAMESPACES (''uri1'' as media, ''uri2'' as live)
SELECT RTRIM(Title) AS ''media:title''
, [Description] AS ''media:description''
, Url AS ''live:link''
, DateCreated AS ''media:pubdate''
, thumbnail AS ''media:thumbnail''
FROM dbo.Videos
WHERE AuthorId = ' + '''' + @auId + '''' +'
FOR XML PATH(''item''), ROOT(''root'')'
|
|
|
|
|
WOW! A lot of code you put there ...
Try delete all the code and replace it with the block bellow
I don't know what are you using @AuName for, but I'm not kidding, everything you posted can be replaced by this:
;
;WITH XMLNAMESPACES ('uri1' as media, 'uri2' as live)
UPDATE dbo.DataFeed
SET items = (
SELECT RTRIM(Title) AS 'media:title'
, [Description] AS 'media:description'
, Url AS 'live:link'
, DateCreated AS 'media:pubdate'
, thumbnail AS 'media:thumbnail'
FROM dbo.Videos
WHERE dbo.Videos.AuthorId = dbo.DataFeed.AuthorId
FOR XML PATH('item'), ROOT('root')
) ;
;
Also, check the below example that I played with, maybe one of the following code styles suits you better:
CREATE TABLE #T(id int IDENTITY(1,1), name nvarchar(10));
INSERT INTO #T (name) SELECT 'Smith';
INSERT INTO #T (name) SELECT 'Yana';
INSERT INTO #T (name) SELECT 'Jane';
INSERT INTO #T (name) SELECT 'Mike';
CREATE TABLE #D(pk int, dsc xml);
INSERT INTO #D (pk, dsc) SELECT 1, NULL;
INSERT INTO #D (pk, dsc) SELECT 2, NULL;
SELECT 'D:EMPTY', * FROM #D;
;
DECLARE @xmlOUT XML;
;WITH XMLNAMESPACES ('uriA1' as media, 'uriA2' as live)
SELECT @xmlOUT = (
SELECT id as 'media:id1'
,name AS 'live:name'
FROM #T
FOR XML PATH('item'), ROOT('root')
);
UPDATE #D
SET dsc = @xmlOUT
WHERE pk = 1;
SELECT 'D:PK1', * FROM #D;
;
;WITH XMLNAMESPACES ('uriB1' as media, 'uriB2' as live)
UPDATE #D
SET dsc = (
SELECT id as 'media:id2'
, name AS 'live:name'
FROM #T
FOR XML PATH('item'), ROOT('root')
)
WHERE pk = 2 ;
SELECT 'D:PK2', * FROM #D;
CREATE TABLE #X(pk int, dsc xml);
INSERT INTO #X (pk, dsc) SELECT 1, NULL;
INSERT INTO #X (pk, dsc) SELECT 2, NULL;
INSERT INTO #X (pk, dsc) SELECT 3, NULL;
INSERT INTO #X (pk, dsc) SELECT 4, NULL;
SELECT 'X:EMPTY', * FROM #X;
;
;WITH XMLNAMESPACES ('uriB1' as media, 'uriB2' as live)
UPDATE #X
SET #X.dsc = (
SELECT #T.id as 'media:id2'
, #T.name AS 'live:name'
FROM #T
WHERE #T.id = #X.pk
FOR XML PATH('item'), ROOT('root')
);
SELECT 'X:FINAL', * FROM #X;
DROP TABLE #D;
DROP TABLE #T;
DROP TABLE #X;
|
|
|
|
|
You seem to have a very exciting job ...
I wish I had a job so demanding ... my new job is kind of boring ... but not for long
|
|
|
|
|
Wow thats a lot simpler. Thanks a lot. I have a bad habit of reverting to cursors when I cant get something to work.
For a Canadian your all right. (Just kidding my sister lives in Toronto)
|
|
|
|
|
I have a wierd issue I am facing. We have a machine that is running DTS pulling data from a SQL database and manipulating it and placing it in a csv file. After a lightning strike the motherboard of the machine had to be replaced, and since then data is being logged to the db just fine however the DTS scripts are no longer executing and the csv files are no longer being created. What would have changed that has stopped DTS scripts from running, since all this data would have been on the hard drive that is running just fine. Are there some services that may not be set to auto start with a hard ware change like a motherboard that need to be changed? I am at a loss as to why this is happenning any help would be greatly appreciated.
|
|
|
|
|
Did you reinstall OS and SQL Server?
|
|
|
|
|
No, all this was intact on the hard drive, we simply replaced the motherboard and fired it up.
|
|
|
|
|
Make sure your SQL Agent is running and that there is a job for it. There is an icon bottom right or go Administrative tools>Services>SQL Server Agent
|
|
|
|
|
|
Hi all,
i have three tables:
table 1 has two colomns: name and id
table 2 has two columns: countrycode and id(id in this table is the forgin key from table one)
table 3 has two columns: countryname and countrycode(countrycode is the forggin key from table two)
now i have to make a query to select the name from table one and the countryname that belongs to that name from table three .
can anyone help me to make this query???
Thanx.
|
|
|
|
|
SELECT t1.name, t3.countryname
FROM [table 1] as t1
INNER JOIN [table 2] as t2 ON t2.id = t1.id
INNER JOIN [table 3] as t3 ON t3.countrycode = t2.countrycode
|
|
|
|
|
Hi i got a DataBase design on Visio and i need to use this DB on MySql server can any one tell me how can i export from Visio or from Ms Sql server thanks
Mohammad Al Hoss
|
|
|
|
|
Hi
Please help me
I have to create a SP.
The secenario is that,
A application calls the SP with a parameter(login), and a string of datas ( Acctid level1 level2; Acctid level1 level2; .......)
UserID AcctID Level1 level2
test testee N Y
eg:
the string of value from application will be as
(SVDB, N, Y; VGBY, Y, B; SCFV, Y, S; SRVD, Y, N; .....)
The SP have to get the fist set of data i.e SVDB, N, Y , check if SVDB exists in the table for that login, if yes update else insert.
Finally do acheck and delete the Acctid not available in above list
Im using SQL 7 server. Please help me in doing this
Thanks in advance
|
|
|
|
|
See below...
DECLARE @s NVARCHAR(4000);
SET @s = '(SVDB, N, Y; VGBY, Y, B; SCFV, Y, S; SRVD, Y, N; SRVD, Y, N; )';
;
SET @s = REPLACE(REPLACE(REPLACE( @s ,' ','') ,'(','') ,')','');
CREATE TABLE #S (pk INT IDENTITY(1,1), line NVARCHAR(100));
CREATE TABLE #T (col1 NVARCHAR(4), col2 NVARCHAR(1), col3 NVARCHAR(1));
DECLARE @p1 INT;
DECLARE @p2 INT;
SET @p1 = 1;
SET @p2 = CHARINDEX(';' , @s);
WHILE @p1 < @p2
BEGIN
INSERT INTO #S (line) SELECT SUBSTRING(@s, @p1, @p2-@p1);
SET @s = SUBSTRING(@s, @p2+1, LEN(@s));
SET @p1 = 1;
SET @p2 = CHARINDEX(';' , @s);
END
DECLARE @k INT;SET @k = 1;
DECLARE @max INT;
SELECT @max = MAX(pk) FROM #S;
WHILE @k < @max
BEGIN
SELECT @s =
'INSERT INTO #T (col1 , col2 , col3) SELECT '''
+ REPLACE( line , ',', ''',''') + '''' FROM #S WHERE pk = @k;
EXEC(@s);
SET @k = @k + 1;
END
DROP TABLE #S;
SELECT * FROM #T;
;
DROP TABLE #T;
Tell me please if this works.
Good luck!
modified on Thursday, July 10, 2008 1:38 PM
|
|
|
|
|
Hi,
we can use IN clause to check condition in list of data
eg: Select * from table where fieldname IN('value1','value2');
but I have to use pattern matching together with this
can I use LIKE clause?
Can Anybody help ?
Thanks in Advance,
Soni
|
|
|
|
|
Are you hard-coding the values in the IN clause, or is list of values getting selected from another table?
|
|
|
|
|
Hi.
I have a stored procedure, and it's working fine.
One of the input parameters is XML (@p_xml) and is processed like this:
DECLARE @docHandle int
EXEC sp_xml_preparedocument @docHandle OUTPUT, @p_xml
SELECT * INTO #raw_table
FROM
OPENXML(@docHandle, '//NODE', 2)
The problem is when the XML is really big (~20 MB with ~35000 nodes). Then the OPENXML statement uses 7-8 minutes to finish.
Is there any way to speed up OPENXML, or is there any other workaround ?
I have tried both select into and insert into and both temp table and table variable. All with the same result.
Could someone help me ?
Kjetil
|
|
|
|
|
I doubt it. Its not the fast thing around. BTW, with the code shown, you do realise you are locking most of the system tables in your tempdb database for the 7-8 minutes it takes to run. A select into locks system tables for the duration of its run, this could seriously impact other users.
Sorry I can't help further.
Bob
Ashfield Consultants Ltd
|
|
|
|
|