Showing posts with label friends. Show all posts
Showing posts with label friends. Show all posts

Tuesday, March 27, 2012

Convert .MDF to .bak

hi friends i am using vwd 2005 i created a project now i want to upload it on the server, but i want which database i used in the database convert it into .bak file for upload it on the server how i convert it, i don't have MS SQL SERVER 2005 or any except vwd 2005.

Whthout the SQL server where you had the DB at first place .. ??

Sunday, March 25, 2012

Conversion of query from Oracle to SQL Server

Hi Friends,
Need ur help desperately. I am stuck with one of the queries which i had written in Oracle and need the same in SQL Server.Please have a look at the following query :

select * from r_tin_1099_info where instr(translate( nm_ctrl_cd , '~!@.#$%^&*()_+}{":?><`-=]['''';/., ', '*******************************' ),'*') > 0;

Basically my purpose is to replace the values in column NM_CTRL_CD having wild card characters with '*' and then select this rows to display.

However i am not able to run the same query in SQL Server since TRANSLATE is not a built in func. I have tried a lot to replace it but could only one func : REPLACE . But the same will not replace any one of the above wild characters but will replace the entire pattern.Please note that it should be able replace even if one of the wild card characters are present in the string and not necessarily the entire pattern shown above.

please reply ASAP since i am working and need this query to fix a defect.

Thanks in advance.Hi all,
Can somebody please reply to my query mentioned above !!!|||I'd suggest using:SELECT *
FROM r_tin_1099_info
WHERE nm_ctrl_cd LIKE '%[]~!@.#$%^&*()_+}{":?><`-=[]%'
-PatP|||Hey thanks a ton... I will try this out and let you know about the results !!!|||Hi,
The query u have sent does not return any result even though the data is there in the table.Can you please help us out with the query !!

Thanks|||Sorry, I was trying to avoid using escape characters and that got me into trouble. A better solution is:SELECT *
FROM r_tin_1099_info
WHERE nm_ctrl_cd LIKE '%[~!@.#$%^&*()_+}{":?><`x-=x]['';/., ]%' ESCAPE 'x'-PatP|||hey Pat... thanks a lot.. this is working fine... just another question... do u knw any equivalent func for TRANSLATE(in DB2)... bcoz i have a query in DB2 which needs to be translated in SQL Server and since TRANSLATE is not a built in func.. i am not able to execute the same query. the query is as follows:

update r_tin_1099_info set nm_ctrl_cd = substr(replace(translate( coalesce(last_nm,tin_nm_1), '', '~!@.#$%^&*()_+}{":?><`-=]['''';/., ' ),' ',''),1,4) where locate('*',translate( nm_ctrl_cd , '*******************************', '~!@.#$%^&*()_+}{":?><`-=]['''';/., ' )) > 0

I know i mite be asking to much from you.. but it will gr88 if u can guide me with this query as well !!

Thanks.|||Because the second argument to the Translate() call is an empty string, the Translate function will do nothing, it is meaningless so it can be discarded. That leaves you with:UPDATE r_tin_1099_info
SET nm_ctrl_cd = substr(replace(coalesce(last_nm, tin_nm_1), ' ', ''), 1, 4)
WHERE nm_ctrl_cd LIKE '%[~!@.#$%^&*()_+}{":?><`x-=x]['';/., ]%' ESCAPE 'x'-PatP|||hey pat... i tried ur query... its executing without any errors but doesnt seem to update the records... the values having wild characters are not updated and still contain the wild characters... Can you please help me out with this

thanks.|||If you can tell me what you want, I can probably help. The code that you posted in your last question ought to have exactly the same effect as the code that I posted in response to it, but that doesn't appear to be what you actually want.

As I've given you several examples to work from, you ought to be able to get pretty close to what you want on your own. If not, please post:

1) whatever DML you have working
2) A DDL script to build your schema
3) At least a few sample rows of data (BCP native format would be preferred)
4) An example of the output that you'd like from your query

I'll help you, but I can't read your mind and I won't actually do your job for you.

-PatP

Sunday, February 19, 2012

constructing strings from table

Hi friends,
please help me in selecting values from the table
the record is as follows:
Id HomePhone WorkPhone Mobile Email
20 2323223 323232232 test@.test.com
i have to select values as follows.
Id DeviceType DeviceInfo
20 HomePhone, Mobile, Email 2323223, 323232232, test@.test.com
the one solution is:
select
'HomePhone, Mobile, Email' AS DeviceType
HomePhone + ',' + WorkPhone + ',' + MobilePhone + ',' + Email AS
DeviceInfo
from table where Id = 20
but here the work phone number is not available so that information
has to be truncated...
Thanks in Advance
Arunkumar.D
Use the same thinking as was suggested in my earlier reply:
SELECT
No
,'HomePhone, ' + CASE WHEN WorkPhone IS NOT NULL THEN 'WorkPhone' + ', ' ELSE '' END + 'Mobile' AS
DeviceType
,HomePhone + ', ' + COALESCE(WorkPhone + ', ', '') + Mobile
FROM
(
SELECT 20 AS No, '23232' AS HomePhone, NULL AS WorkPhone, '98327' AS Mobile
) AS x
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Oonz" <arundhaj@.gmail.com> wrote in message
news:1179848438.242226.4580@.n15g2000prd.googlegrou ps.com...
> Hi friends,
> please help me in selecting values from the table
> the record is as follows:
> Id HomePhone WorkPhone Mobile Email
> 20 2323223 323232232 test@.test.com
> i have to select values as follows.
> Id DeviceType DeviceInfo
> 20 HomePhone, Mobile, Email 2323223, 323232232, test@.test.com
>
> the one solution is:
> select
> 'HomePhone, Mobile, Email' AS DeviceType
> HomePhone + ',' + WorkPhone + ',' + MobilePhone + ',' + Email AS
> DeviceInfo
> from table where Id = 20
> but here the work phone number is not available so that information
> has to be truncated...
> Thanks in Advance
> Arunkumar.D
>

constructing strings from table

Hi friends,
i have to select values from the table consider with the following
record:
No HomePhone WorkPhone Mobile
20 23232 98327
the selection have to be done as:
No DeviceType DeviceInfo
20 HomePhone, Mobile 23232, 98327
since there is no value for workphone it have to be removed in both
devicetype and deviceinfo column.
Thanks
Arunkumar.D
No DDL = not tested...
Something like (assuming NULL when you say "no value"):
SELECT
No
,'HomePhone, ' + CASE WHEN WorkPhone IS NULL THEN 'WorkPhone' + ', ' ELSE '' END + 'Mobile' AS
DeviceType
,HomePhone + ', ' + COALESCE(WorkPhone + ', ', '') + Mobile
FROM ...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Oonz" <arundhaj@.gmail.com> wrote in message
news:1179849918.549063.61900@.n15g2000prd.googlegro ups.com...
> Hi friends,
> i have to select values from the table consider with the following
> record:
> No HomePhone WorkPhone Mobile
> 20 23232 98327
> the selection have to be done as:
> No DeviceType DeviceInfo
> 20 HomePhone, Mobile 23232, 98327
> since there is no value for workphone it have to be removed in both
> devicetype and deviceinfo column.
> Thanks
> Arunkumar.D
>
|||> i have to select values from the table consider with the following
> record:
> No HomePhone WorkPhone Mobile
> 20 23232 98327
> the selection have to be done as:
> No DeviceType DeviceInfo
> 20 HomePhone, Mobile 23232, 98327
What about something like:
SELECT No,
CASE WHEN HomePhone IS NULL THEN '' ELSE 'HomePhone' END +
CASE WHEN WorkPhone IS NULL THEN '' ELSE 'WorkPhone' END +
CASE WHEN Mobile IS NULL THEN '' ELSE 'Mobile' END
AS DeviceType,
CASE WHEN HomePhone IS NULL THEN '' ELSE HomePhone END +
CASE WHEN WorkPhone IS NULL THEN '' ELSE WorkPhone END +
CASE WHEN Mobile IS NULL THEN '' ELSE Mobile END
AS DeviceInfo
FROM TableName
(You will need to add a bit of logic to work out where to put the commas)
Rgds,
Gavin

constructing strings from table

Hi friends,
please help me in selecting values from the table
the record is as follows:
Id HomePhone WorkPhone Mobile Email
20 2323223 323232232 test@.test.com
i have to select values as follows.
Id DeviceType DeviceInfo
20 HomePhone, Mobile, Email 2323223, 323232232, test@.test.com
the one solution is:
select
'HomePhone, Mobile, Email' AS DeviceType
HomePhone + ',' + WorkPhone + ',' + MobilePhone + ',' + Email AS
DeviceInfo
from table where Id = 20
but here the work phone number is not available so that information
has to be truncated...
Thanks in Advance
Arunkumar.DUse the same thinking as was suggested in my earlier reply:
SELECT
No
,'HomePhone, ' + CASE WHEN WorkPhone IS NOT NULL THEN 'WorkPhone' + ', ' ELSE '' END + 'Mobile' AS
DeviceType
,HomePhone + ', ' + COALESCE(WorkPhone + ', ', '') + Mobile
FROM
(
SELECT 20 AS No, '23232' AS HomePhone, NULL AS WorkPhone, '98327' AS Mobile
) AS x
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Oonz" <arundhaj@.gmail.com> wrote in message
news:1179848438.242226.4580@.n15g2000prd.googlegroups.com...
> Hi friends,
> please help me in selecting values from the table
> the record is as follows:
> Id HomePhone WorkPhone Mobile Email
> 20 2323223 323232232 test@.test.com
> i have to select values as follows.
> Id DeviceType DeviceInfo
> 20 HomePhone, Mobile, Email 2323223, 323232232, test@.test.com
>
> the one solution is:
> select
> 'HomePhone, Mobile, Email' AS DeviceType
> HomePhone + ',' + WorkPhone + ',' + MobilePhone + ',' + Email AS
> DeviceInfo
> from table where Id = 20
> but here the work phone number is not available so that information
> has to be truncated...
> Thanks in Advance
> Arunkumar.D
>

constructing strings from table

Hi friends,
i have to select values from the table consider with the following
record:
No HomePhone WorkPhone Mobile
20 23232 98327
the selection have to be done as:
No DeviceType DeviceInfo
20 HomePhone, Mobile 23232, 98327
since there is no value for workphone it have to be removed in both
devicetype and deviceinfo column.
Thanks
Arunkumar.DNo DDL = not tested...
Something like (assuming NULL when you say "no value"):
SELECT
No
,'HomePhone, ' + CASE WHEN WorkPhone IS NULL THEN 'WorkPhone' + ', ' ELSE '' END + 'Mobile' AS
DeviceType
,HomePhone + ', ' + COALESCE(WorkPhone + ', ', '') + Mobile
FROM ...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Oonz" <arundhaj@.gmail.com> wrote in message
news:1179849918.549063.61900@.n15g2000prd.googlegroups.com...
> Hi friends,
> i have to select values from the table consider with the following
> record:
> No HomePhone WorkPhone Mobile
> 20 23232 98327
> the selection have to be done as:
> No DeviceType DeviceInfo
> 20 HomePhone, Mobile 23232, 98327
> since there is no value for workphone it have to be removed in both
> devicetype and deviceinfo column.
> Thanks
> Arunkumar.D
>|||> i have to select values from the table consider with the following
> record:
> No HomePhone WorkPhone Mobile
> 20 23232 98327
> the selection have to be done as:
> No DeviceType DeviceInfo
> 20 HomePhone, Mobile 23232, 98327
What about something like:
SELECT No,
CASE WHEN HomePhone IS NULL THEN '' ELSE 'HomePhone' END +
CASE WHEN WorkPhone IS NULL THEN '' ELSE 'WorkPhone' END +
CASE WHEN Mobile IS NULL THEN '' ELSE 'Mobile' END
AS DeviceType,
CASE WHEN HomePhone IS NULL THEN '' ELSE HomePhone END +
CASE WHEN WorkPhone IS NULL THEN '' ELSE WorkPhone END +
CASE WHEN Mobile IS NULL THEN '' ELSE Mobile END
AS DeviceInfo
FROM TableName
(You will need to add a bit of logic to work out where to put the commas)
Rgds,
Gavin

constructing strings from table

Hi friends,
please help me in selecting values from the table
the record is as follows:
Id HomePhone WorkPhone Mobile Email
20 2323223 323232232 test@.test.com
i have to select values as follows.
Id DeviceType DeviceInfo
20 HomePhone, Mobile, Email 2323223, 323232232, test@.test.com
the one solution is:
select
'HomePhone, Mobile, Email' AS DeviceType
HomePhone + ',' + WorkPhone + ',' + MobilePhone + ',' + Email AS
DeviceInfo
from table where Id = 20
but here the work phone number is not available so that information
has to be truncated...
Thanks in Advance
Arunkumar.DUse the same thinking as was suggested in my earlier reply:
SELECT
No
,'HomePhone, ' + CASE WHEN WorkPhone IS NOT NULL THEN 'WorkPhone' + ', ' ELS
E '' END + 'Mobile' AS
DeviceType
,HomePhone + ', ' + COALESCE(WorkPhone + ', ', '') + Mobile
FROM
(
SELECT 20 AS No, '23232' AS HomePhone, NULL AS WorkPhone, '98327' AS Mobile
) AS x
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Oonz" <arundhaj@.gmail.com> wrote in message
news:1179848438.242226.4580@.n15g2000prd.googlegroups.com...
> Hi friends,
> please help me in selecting values from the table
> the record is as follows:
> Id HomePhone WorkPhone Mobile Email
> 20 2323223 323232232 test@.test.com
> i have to select values as follows.
> Id DeviceType DeviceInfo
> 20 HomePhone, Mobile, Email 2323223, 323232232, test@.test.com
>
> the one solution is:
> select
> 'HomePhone, Mobile, Email' AS DeviceType
> HomePhone + ',' + WorkPhone + ',' + MobilePhone + ',' + Email AS
> DeviceInfo
> from table where Id = 20
> but here the work phone number is not available so that information
> has to be truncated...
> Thanks in Advance
> Arunkumar.D
>

constructing strings from table

Hi friends,
i have to select values from the table consider with the following
record:
No HomePhone WorkPhone Mobile
20 23232 98327
the selection have to be done as:
No DeviceType DeviceInfo
20 HomePhone, Mobile 23232, 98327
since there is no value for workphone it have to be removed in both
devicetype and deviceinfo column.
Thanks
Arunkumar.DNo DDL = not tested...
Something like (assuming NULL when you say "no value"):
SELECT
No
,'HomePhone, ' + CASE WHEN WorkPhone IS NULL THEN 'WorkPhone' + ', ' ELSE ''
END + 'Mobile' AS
DeviceType
,HomePhone + ', ' + COALESCE(WorkPhone + ', ', '') + Mobile
FROM ...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Oonz" <arundhaj@.gmail.com> wrote in message
news:1179849918.549063.61900@.n15g2000prd.googlegroups.com...
> Hi friends,
> i have to select values from the table consider with the following
> record:
> No HomePhone WorkPhone Mobile
> 20 23232 98327
> the selection have to be done as:
> No DeviceType DeviceInfo
> 20 HomePhone, Mobile 23232, 98327
> since there is no value for workphone it have to be removed in both
> devicetype and deviceinfo column.
> Thanks
> Arunkumar.D
>|||> i have to select values from the table consider with the following
> record:
> No HomePhone WorkPhone Mobile
> 20 23232 98327
> the selection have to be done as:
> No DeviceType DeviceInfo
> 20 HomePhone, Mobile 23232, 98327
What about something like:
SELECT No,
CASE WHEN HomePhone IS NULL THEN '' ELSE 'HomePhone' END +
CASE WHEN WorkPhone IS NULL THEN '' ELSE 'WorkPhone' END +
CASE WHEN Mobile IS NULL THEN '' ELSE 'Mobile' END
AS DeviceType,
CASE WHEN HomePhone IS NULL THEN '' ELSE HomePhone END +
CASE WHEN WorkPhone IS NULL THEN '' ELSE WorkPhone END +
CASE WHEN Mobile IS NULL THEN '' ELSE Mobile END
AS DeviceInfo
FROM TableName
(You will need to add a bit of logic to work out where to put the commas)
Rgds,
Gavin

constructing strings from table

Hi friends,
please help me in selecting values from the table

the record is as follows:
Id HomePhone WorkPhone Mobile Email
20 2323223 323232232 test@.test.com
i have to select values as follows.

Id DeviceType DeviceInfo
20 HomePhone, Mobile, Email 2323223, 323232232, test@.test.com
the one solution is:
select
'HomePhone, Mobile, Email' AS DeviceType
HomePhone + ',' + WorkPhone + ',' + MobilePhone + ',' + Email AS
DeviceInfo
from table where Id = 20

but here the work phone number is not available so that information
has to be truncated...

Thanks in Advance
Arunkumar.DOonz (arundhaj@.gmail.com) writes:

Quote:

Originally Posted by

Hi friends,
please help me in selecting values from the table
>
the record is as follows:
Id HomePhone WorkPhone Mobile Email
20 2323223 323232232 test@.test.com
>
i have to select values as follows.
>
Id DeviceType DeviceInfo
20 HomePhone, Mobile, Email 2323223, 323232232, test@.test.com
>
>
the one solution is:
select
'HomePhone, Mobile, Email' AS DeviceType
HomePhone + ',' + WorkPhone + ',' + MobilePhone + ',' + Email AS
DeviceInfo
from table where Id = 20
>
but here the work phone number is not available so that information
has to be truncated...


Provided that WorkPhone is blank, the query above make sense to me.
The output would be "2323223,,323232232,test@.test.com". But if the
double comma wasn't there, how would you know which number that is
missing?

If WorkPhone is NULL, the entire expression will be NULL. In this
case you must use coalesce(WorkPhone, '') and similar for the other
columns.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||On May 23, 2:48 am, Erland Sommarskog <esq...@.sommarskog.sewrote:

Quote:

Originally Posted by

Oonz (arund...@.gmail.com) writes:

Quote:

Originally Posted by

Hi friends,
please help me in selecting values from the table


>

Quote:

Originally Posted by

the record is as follows:
Id HomePhone WorkPhone Mobile Email
20 2323223 323232232 t...@.test.com


>

Quote:

Originally Posted by

i have to select values as follows.


>

Quote:

Originally Posted by

Id DeviceType DeviceInfo
20 HomePhone, Mobile, Email 2323223, 323232232, t...@.test.com


>

Quote:

Originally Posted by

the one solution is:
select
'HomePhone, Mobile, Email' AS DeviceType
HomePhone + ',' + WorkPhone + ',' + MobilePhone + ',' + Email AS
DeviceInfo
from table where Id = 20


>

Quote:

Originally Posted by

but here the work phone number is not available so that information
has to be truncated...


>
Provided that WorkPhone is blank, the query above make sense to me.
The output would be "2323223,,323232232,t...@.test.com". But if the
double comma wasn't there, how would you know which number that is
missing?
>
If WorkPhone is NULL, the entire expression will be NULL. In this
case you must use coalesce(WorkPhone, '') and similar for the other
columns.
>
--
Erland Sommarskog, SQL Server MVP, esq...@.sommarskog.se
>
Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books...
Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx- Hide quoted text -
>
- Show quoted text -


The solution i have given is a static one.
The above solution holds good when all the column have value in it.
but when one column, say "HomePhone" is not available the resulting
table should build as

Id DeviceType DeviceInfo
20 Mobile, Email 323232232, t...@.test.com

please help me in this regards.|||Oonz (arundhaj@.gmail.com) writes:

Quote:

Originally Posted by

The solution i have given is a static one.
The above solution holds good when all the column have value in it.
but when one column, say "HomePhone" is not available the resulting
table should build as
>
>
Id DeviceType DeviceInfo
20 Mobile, Email 323232232, t...@.test.com
>
please help me in this regards.


Use the CASE exprssion:

SELECT DeviceType = CASE WHEN HomePhone IS NOT NULL
THEN HomePhone + ','
ELSE ''
END +
CASE WHEN WorkPhone IS NOT NULL
THEN WorkdPhone + ','
ELSE ''
END ...

It gets a little devilish if the email is missing as you may end with a
trailing comma, but maybe you can live wity that.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

Tuesday, February 14, 2012

constraints implemented in Triggers and replication

Hi Friends,
I have some problems with my merge replication because i have the
constraints created with Erwin implemented in triggers not like foreign
keys, i'm looking for a tool or strategy for converting this constraints to
FK's.
Please help.
Hi Paul,
My problem is in my merge replication. I have'nt Foreign Keys in then BD,
when the replication run, the insert or update or delete statment cause error
because dont have a order of insertion or update or delete because in our
application we have a order.
think you.
Please help.
"Paul Ibison" wrote:

> What problems are you seeing from the triggers? If you
> don't want them to fire as a result of the replication
> process, you can specify NOT FOR REPLICATION on the
> trigger definition. If the problem is that the triggers
> are causing recursion, you can investigate
> sp_check_for_sync_trigger.
> HTH,
> Paul Ibison (SQL Server MVP)
>
>
|||Chouaib,
using NOT FOR REPLICATION in the trigger definition will
mean that the triggers which you have to check
Referential Integrity will not fire during the
replication process. This would seem to fix your issue?
Rgds,
Paul Ibison (SQL Server MVP)
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||thank you paul,
i try that but i have more that one thousands of triggers.
regards.
"Paul Ibison" wrote:

> Chouaib,
> using NOT FOR REPLICATION in the trigger definition will
> mean that the triggers which you have to check
> Referential Integrity will not fire during the
> replication process. This would seem to fix your issue?
> Rgds,
> Paul Ibison (SQL Server MVP)
> (recommended sql server 2000 replication book:
> http://www.nwsu.com/0974973602p.html)
>
|||If you script them out into a single file using EM, you
might be asble to replace 'AS' with 'NOT FOR REPLICATION
AS' then run the script.
Rgds,
Paul Ibison (SQL Server MVP)
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||THANK YOU PAUL'
I DO THAT.
"Paul Ibison" wrote:

> If you script them out into a single file using EM, you
> might be asble to replace 'AS' with 'NOT FOR REPLICATION
> AS' then run the script.
> Rgds,
> Paul Ibison (SQL Server MVP)
> (recommended sql server 2000 replication book:
> http://www.nwsu.com/0974973602p.html)
>