Sqlcmd: The -W and the -y/-Y options are mutually exclusive

25 views Asked by At

I am working on SQL server task. I need a sqlcmd result file with complete records with headers.

Here is the command and error message below

sqlcmd -S [Server_Name] -U [User_Name] -P [Password] -d [DB_Name] -W -y0 -Q "select test_desc from Test0 "   1>>Result.txt

Error:

Sqlcmd: The -W and the -y/-Y options are mutually exclusive.

Has anyone had this problem before? Thoughts on how to solve it?

Actual Data:

test_desc

dkbrgewejdnxd dsvdwjih32i9885y3ehdc svajns seebdjsxnbyewnj92348y3384uhbc xmsbhfgwqhdnscdhvrewdusjijeurgadsbcnnwj0i9128489823hrfhbdcx  dcuyxghbscvafvagwefdhewfdsh47346221bhv3g4h321bj14bh5vj4jh3b2jb23283234e2hv234821`13142414v42vhv4jh1b2j1bjhb412489ywq8e8772845478129804217hbscvafvagwefdhewfdsh47346221bhv3g4h321bj14bh5vj4jh3b2jb23283234e2hv234821`13142414v42vhv4jh1b2j1bjhb412489ywq8e8772845478129804217dkbrgewejdnxd dsvdwjih32i9885y3ehdc svajns seebdjsxnbyewnj92348y3384uhbc xmsbhfgwqhdnscde2hv234821`13142414v42vhv4jh1b2j1bjhb412489ywq8e8772845478129804217dkbrgewejdnxd dsvdwjih32i9885y3ehdc svajns s fqwhvchedcuyxghbscvafvagwefdhewfdsh47346221bhv3g4h321bj14bh5vj4jh3b2jb23283234e2hv234821`13142414v42vhv4jh1b2j1bjhb412489ywq8e8772845478129804217dkbrgewejdnxd dsvdwjih32i9885y3ehdc svajns seebdjsxnbyewnj92348y3384uhbc xmsbhfgwqhdnscdhvrewdusjijeurgadsbcnnwj0i91=

-W command:

-W command is not useful for large data. the columns are getting truncated at 256 bytes.

sqlcmd -S [Server_Name] -U [User_Name] -P [Password] -d [DB_Name] -W -Q "select test_desc from Test0 " >> Result.txt


Result.txt:

test_desc

---------

dkbrgewejdnxd dsvdwjih32i9885y3ehdc svajns seebdjsxnbyewnj92348y3384uhbc xmsbhfgwqhdnscdhvrewdusjijeurgadsbcnnwj0i9128489823hrfhbdcx ÿdcuyxghbscvafvagwefdhewfdsh47346221bhv3g4h321bj14bh5vj4jh3b2jb23283234e2hv234821`13142414v42vhv4jh1b2j1bjhb412489ywq8e8772

-y0 command:

-y0 command returns complete records of a column, but column header is missing.

sqlcmd -S [Server_Name] -U [User_Name] -P [Password] -d [DB_Name] -y0 -Q "select test_desc from Test0 " >> Result.txt


Result.txt:

dkbrgewejdnxd dsvdwjih32i9885y3ehdc svajns seebdjsxnbyewnj92348y3384uhbc xmsbhfgwqhdnscdhvrewdusjijeurgadsbcnnwj0i9128489823hrfhbdcx ÿdcuyxghbscvafvagwefdhewfdsh47346221bhv3g4h321bj14bh5vj4jh3b2jb23283234e2hv234821`13142414v42vhv4jh1b2j1bjhb412489ywq8e8772845478129804217hbscvafvagwefdhewfdsh47346221bhv3g4h321bj14bh5vj4jh3b2jb23283234e2hv234821`13142414v42vhv4jh1b2j1bjhb412489ywq8e8772845478129804217dkbrgewejdnxd dsvdwjih32i9885y3ehdc svajns seebdjsxnbyewnj92348y3384uhbc xmsbhfgwqhdnscde2hv234821`13142414v42vhv4jh1b2j1bjhb412489ywq8e8772845478129804217dkbrgewejdnxd dsvdwjih32i9885y3ehdc svajns s fqwhvchedcuyxghbscvafvagwefdhewfdsh47346221bhv3g4h321bj14bh5vj4jh3b2jb23283234e2hv234821`13142414v42vhv4jh1b2j1bjhb412489ywq8e8772845478129804217dkbrgewejdnxd dsvdwjih32i9885y3ehdc svajns seebdjsxnbyewnj92348y3384uhbc xmsbhfgwqhdnscdhvrewdusjijeurgadsbcnnwj0i91=

(1 rows affected)
0

There are 0 answers